Sharing libraries between .Net and .Net compact framework

G

Guest

Can I create a single library that works on CE devices, or pocketPCs, or
whatever is using the .Net Compact Framework, and also on the full framework.

I have an application that talks to industrial equipment, and I want to have
a laptop version and a Pocket PC version. There are a set of common data
classes that I want to share between the two versions of the application,
because they are both accessing the same data, just displaying it
differently. However, I can't create a reference to the library that
contains the data classes in the CE based project, because the library wasn't
compiled as a device library.

All the functions in the library are available in the CF. Is there any way
I can access a single piece of code in both frameworks?
 
P

Paul G. Tobey [eMVP]

This has been asked over and over. You can search the archives of the group
via GoogleGroups:

http://groups.google.com/group/micr...tframework?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8

You need to carefully consider your terminology. Are you sure you mean
"library"? You *can* compile a managed code DLL for .NET CF and that DLL,
assuming it doesn't do anything Windows CE-specific, will also run on the
desktop with no changes. You can't do the opposite, though.

Paul T.
 
N

Norman Rericha

I encourage all drivers be written for CE and Win32. This however takes
some time and effort. To be the most effective, you should also have a
source control solution running (Vault, VSS, etc)

First create a empty project for Win32. (MyLibrary)
Next Create a empty project for WinCE (MyLibraryCE)
This is important because the comipler is different based on the OS you
are building for. The code is similar but not exact, so this helps with
it.

Copy the project file MyLibraryCE into the same folder as MyLibrary
The directory tree should look something like this

[ROOT]\Libraries\MyLibrary
MyLibrary.proj
MyLibraryCE.proj

Open MyLibraryCE and create a new compilation symbol in the properites.
I usually name mine WIN_CE.

You can now develop your code. I recommend developing CE first since it
is more limited. When you write code that is CE only (P/Invokes) you
surround it with #if WIN_CE or #if !WIN_CE. This will add/remove
features at compile time based on the project loaded.

Going back to your Win32 library. Simply "Add Existing Items" and
include all of your already written files. There will be tweaking and
such to get it running 100%. Remember when you add Win32 specific code
to surround it with #if !Win_CE. Since the WIN_CE define isn't set it
will not include CE code.

I usually set my assembly names to be the same (MyLibrary.dll). This
works well with libraries if they are not heavily reliant on the full
framework.

--
I hope this helps

--
Norman Rericha
Senior Software Engineer
Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top