Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile a library on .NET Framework & .NET Compact Framework?

I'm developing a technical library class that can be used on both types of Frameworks (Compact or not).

What is the best way to develop such library? Using by default the .NET features (for XP Embedded) and do restrictions when using Windows CE (using CF.NET) ?

Thanks.

like image 539
Arnaud F. Avatar asked Dec 27 '10 09:12

Arnaud F.


2 Answers

I usually approach this by having separate dlls per playform, so I can use available platform features when possible (often neither is a strict subset/superset, and aiming for the intersection is overly limiting if you want the beat performance etc).

Most features are common though, so the amount of #if code (with feature-specific build symbols) is often minimal.

To avoid issues with forgetting to add project files, I use a recursive wildcard in the csproj, so all .cs files are included automatically.

like image 170
Marc Gravell Avatar answered Oct 08 '22 08:10

Marc Gravell


I find that there are two approaches to sharing library classes between .NET and .NET CF code bases.

The Code is Identical

Often the libraries can be identical, particularly if they are basic libraries that have calculations, or business classes that are identical. For non-UI libraries this is often the case since .NET CF is mostly a subset of .NET.

In this case, you can just build a device project and include it for your full windows project. You will get a warning that you are loading a device project, but if you haven't used any CF specific code, it is fine.

The Code is Very Similar, but Different

In this case, I create two project and thus two assemblies. One of these assemblies I make the primary one and include all of the files that are used. In the second I add the files as links to include them as references, so any updates are reflected. Then I use ifdefs for any special cases where they may differ.

like image 37
skeeve Avatar answered Oct 08 '22 08:10

skeeve