views:

69

answers:

3

My solution consists of 2 executable projects and a couple dlls. Project1 is a Smart Device Project, Project2 is a Windows Forms Project.
Both projects use the same libraries, the reason of that is I want to test my libraries on PC before I deploy it on the device.

The problem is that the DLL project type can be Smart Device Class Library or Class Library, not both. I cannot add a reference from SD project to WF and vice versa. I was able to add reference from SD project to a dll file (generated from Class Library project) instead of the project itself, but for some reason I got the message "cannot load XXX type from YYY assembly". It doesn't depend on my code, because when I created separate project for the same sources, everything was fine.

The only solution I've found is to create 2 types of projects for each library, but I don't know how to make 2 projects based on the same sources.

+6  A: 

You can add all of the files normally to one project.

You can then right-click the other project, click Add, Existing File, select the files, click the down arrow next to the Add button, and click Add as Link.

SLaks
It answers my question. Thanks
mack369
Yes but there is an issue with this solution. You can in the PC application modify the code to use only full framework tools which will break the smart framework version but will still build fine in your "full framework" app.
Quibblesome
@Quibblesome: All you need to do is fit F6 and it will build both.
SLaks
True but the correct solution is to reference one smartdevice library from both projects. This solution has an overhead of another unnecessary csproj file. Although I appreciate it is possibly a simpler solution to understand.
Quibblesome
+1  A: 

Normally, you can reference a Smart Device Class Library project from either a Smart Device EXE project or a full-framework WinForms EXE project.

However, it is possible to reference .NetCF-only components within the Smart Device class library that will make the DLL not work when referenced from a full-framework EXE project.

What assemblies are actually mentioned in your error message (I'm assuming it doesn't literally say "XXX" and "YYY")?

MusiGenesis
1. When I'm adding a reference from Full-framework EXE project, I get the message: "Adding a reference to a device project may produce unexpected results. Do you want to continue?" - it doesn't encourage me for this solution2. XXX is name of my class, YYY is the assembly where it should be located.
mack369
+1  A: 

I'm not sure if you understood MusiGenesis's answer correctly.

The premise is to create your libraries as smartcard device class libraries and then reference those smart device class libraries in both projects "full framework" and "WinCE".

Now SmartDevice applications cannot reference Full Framework libraries but Full Framework applications CAN reference smart device libraries.

So your final project assortment might look like this:

  • Library.dll - A smart device library
  • FullFramework.exe a Windows Forms application for Full Framework that references Library.dll
  • WinCE.exe a Compact Framework application that references Library.dll

The above configuration will build fine. Just be aware of certain differences between compact framework and full framework.

Quibblesome
I do understand MusiGenesis's answer. When I add reference in FullFramework.exe application to Library.dll (a smart device library) I get the message: "Adding a reference to a device project may produce unexpected results. Do you want to continue?"
mack369
You click "yes" and ignore that message. Tbh that message is a bit misleading. It wont produce unexpected results.
Quibblesome