views:

747

answers:

3

Hi Guys,

Quick question (I hope), how do I include a window 6 class library dll in a standard net project? I seem to be able to just add a reference via VS in earlier editions of windows mobile projects, but not with version 6. From what I read it should be possible as long as not CE specific libraries have been used.

Any help appreciated.

Thanks, Chris.

Edit:

Not what I have found, I have done the following:

1) Create new windows mobile 6 class library (CF .NET dll)

2) Create new standard class library(Standard .NET dll)

3)Try to include the mobile 6 lib to the standard one

Here I get:

"A reference to cannot be added".

+1  A: 

If this is a CF .NET dll you can add it as a reference (no matter what version). If it is a native code library, you can't. You need to create a .NET wrapper around this dll (using P/Invoke) and add this dll to your project. You need to take care that the native dll is present at runtime.

kgiannakakis
Its not native code, it is a CF .NET dll. See edit for error.
Owen
A: 

From my experience you simply cant, which really sucks!!! So much for compile once, run everywhere.

In any case, one solution I found is:

  1. Code your project in a CF class library or a Win32 library, it doesn't matter which (Project1).
  2. Add a new project of the other type (Project2).
  3. Duplicate the folder structure under Project2 so that it mirrors Project1.
  4. Right click on Project2 and select Add --> Existing Item...
  5. Navigate to the Project1's folder and select all the files that you are interested in (remember to selectively avoid .designer.cs files, such as the .designer.cs for .resx).
  6. To the right of the Add button (Add |V) you will see a downward pointing arrow, click it.
  7. Add as Link.
  8. Repeat the same process for all the folders under Project2.

The point is that even though you now have two assemblies, any changes to a cs file are reflected in all of them. This is how XNA GameStudio does things, and how I have grappled with the CF for phones in the past.

Once you have done the initial 'port' things go pretty quickly. The CF project should have a debug symbol (POCKETPC or SMARTPHONE IIRC), but I recommend you add MOBILE so that you can share CF code between PocketPC and SmartPhone projects.

I am thinking of writing a tool to mirror projects, if you are interested say so in the comment and I will make time to do it (right now I am not working on any CF stuff).

It should be possible to automate this with an MSBUILD task as well. But unfortunately by generating a csproj file at build time, one looses intellisense at code time.

Jonathan C Dickinson
This doesn't seem to sit well with me, as before the files are compiled down they are simply text files. It should be a matter of switching the compiler and allowing it should determine which "System.Data" (or whatever reference) I import (full or CE).
Owen
A: 

Ive found the answer to my own question here:

http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/c0cae024-a9a2-43bd-9d37-69bc9a9338c7/

Turns out that VB.NET projects have trouble referencing CF projects created in VB.NET. All good fun.

Owen