Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / January 2006

Tip: Looking for answers? Try searching our database.

Sharing libraries between .Net and .Net compact framework

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 20 Jan 2006 16:21 GMT
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?
Paul G. Tobey [eMVP] - 20 Jan 2006 16:36 GMT
This has been asked over and over.  You can search the archives of the group
via GoogleGroups:

http://groups.google.com/group/microsoft.public.dotnet.framework.compactframewor
k?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.

> 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
[quoted text clipped - 13 lines]
> way
> I can access a single piece of code in both frameworks?
Daniel Moth - 20 Jan 2006 21:26 GMT
You have two options. Start here:
http://www.danielmoth.com/Blog/2004/09/share-code-if-fullframe_17.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/

> 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
[quoted text clipped - 13 lines]
> way
> I can access a single piece of code in both frameworks?
Norman Rericha - 20 Jan 2006 21:26 GMT
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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.