Shared Library (dll) between .net Micro and .net 4.0 client profile

I have my .net Micro project (Fez Panda 2) and a .net 4.0 project (a TCP Server on Win7) and I want to be able to share some simple code (mainly just objects). I thought my only limitation was going to be that I could only use code that worked on the .net micro framework in the dll, but that doesn’t seem to be it.

I get this error
"Warning 1 The project ‘SharedLibrary’ cannot be referenced. The referenced project is targeted to a different framework family (.NETMicroFramework)
"
and this comes from my Server project.

Is there a way I can share code between these two projects?

Take a look at .NET Micro Framework Documentation to have an idea of what APIs are share and what dlls to add to get them:

And here are the sockets classes supported on FEZ Panda II which are like 99% compatible with .NET’s
http://www.ghielectronics.com/downloads/NETMF/WIZnet%20Library%20Documentation/Index.html

Here where I got the links from:

I might be missing something here and I have looked over those links already. I don’t understand how that information will help me do what I want to do.

I want to create a dll that I can use with both my Fez Panda 2 and TCP Server (.net 4.0 Client Profile). (I don’t like having duplicate code)

I think Joe misunderstood your question.

You can have shared code but you have to compile the DLL twice still I believe. I never tried it myself.

I believe you’ll have to share the source files not the project files. .NET Micro Framework is not going to be an available target option within a regular .NET project & vice versa. Just add your .cs files to a NETMF project and you should be in business as long as you’re using all compatible syntax.

Thanks, that what I ended up doing for the time being, maybe forever…

If your PC side app is an emulator then you can share the DLL provided it contains no hardware specific calls. You can set up things that the emulator on PC can talk to actual hardware and it will seem like there are two devices involved. Interesting experiment but not really useful in practice.

Practically it is much easier to share a source file and compile twice.

There is no reason this can’t be done with some hacking. The NETMF dll is actual MSIL and Reflector reads it. I think it is Visual Studio that is trying to protect you from doing something out of the ordinary.

@ XenoPuTtSs: you can have two libraries in your project, one for regular .net and one for net mf. Implement your logic in the first one and only add links to cs files in the second one. You can see this approach in netmf toolkit available on codeplex. This results in two different assemlblies but no duplicated code.

Install “Linked Project” Extension to Visal Studio.

After you can create 1 main project and 1 linked project share source code with first.

When you add new file to first, it’s automaticaly added to second.

Thanks everyone!

I ended up doing Hervé Tinant suggestion (which is an easy way of doing what Gralin suggested).

The extension is called “Project Linker”.

From BillKrat’s Blog (http://www.global-webnet.net/blogengine/post/2010/09/12/VS2010-Project-linker.aspx) I did
The steps follow for Visual Studio 2010:

Click on Tools
Click on Extension Manager
Click on “Online Gallery”
Search for “Linker” (top right textbox)
Click on the [download] button on “Project Linker”
Click [Install] when prompted.
System will restart VS2010

and then on one project I wanted to be the copy, i deleted the files, added the link to the original project, and then (removed/readded) the files to the original project.

Everything works great!

Thanks for your help everyone!!