C# - Sharing assembly between projects?
-
Hi all, I have a little problem.... I have a C# Winforms app that sends serialised data to a Pocket PC via TCP/IP, the transmission isnt the problem, but the library Objects.dll was built as a windows library, and even though they are simple objects Visual Studio 2005 wont let me add the project reference to the Pocket PC application because its not a Smart Device Library.... How can i get round this problem? Ideally i want one single assembly that will work for both Winforms and PocketPC client (.net2), using vs2005 Cheers guys! Will
-
Hi all, I have a little problem.... I have a C# Winforms app that sends serialised data to a Pocket PC via TCP/IP, the transmission isnt the problem, but the library Objects.dll was built as a windows library, and even though they are simple objects Visual Studio 2005 wont let me add the project reference to the Pocket PC application because its not a Smart Device Library.... How can i get round this problem? Ideally i want one single assembly that will work for both Winforms and PocketPC client (.net2), using vs2005 Cheers guys! Will
Hi Will, Create a new Smart Device (PDA) class library project in your solution. Right-click the project and select Add->Existing Items. Navigate to the directory that contains your library files, and select them. In the navigation window, rather than clicking the "Add" button, click the small dropdown arrow on the side of the "Add" button. It will show a menu that says "Add as Link." Select that option. You'll see the files show up in your project with small shortcut icons attached to them. When you compile this project, it will compile the files using the Compact Framework compiler to this Smart Device project's output directory (not to the original WinForms project's directory). This way, you have two separate projects with the same source files, that will compile to their respective target frameworks. Making edits in the files will show up in both projects. NOTE: If you open the files from the desktop project, you will get Intellisense for the full framework. If you open the files from the PDA project, you will get Intellisense for the Compact Framework. Even though it is exactly the same files, Visual Studio will determine which editing environment to use based on which project opened the files. ALSO: If you need code specific to either framework, define a symbol in your Compact Framework project properties that you can use for #if..#endif pragmas. This way you can add custom code for each framework that won't interfere with the compiled code in the other framework. For example: Say you define a symbol "NET_CF" in your Compact Framework project. In your code you can do something like this: #if NET_CF ... CF code... #else ... Desktop code... #endif Hope this helps
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
-
Hi Will, Create a new Smart Device (PDA) class library project in your solution. Right-click the project and select Add->Existing Items. Navigate to the directory that contains your library files, and select them. In the navigation window, rather than clicking the "Add" button, click the small dropdown arrow on the side of the "Add" button. It will show a menu that says "Add as Link." Select that option. You'll see the files show up in your project with small shortcut icons attached to them. When you compile this project, it will compile the files using the Compact Framework compiler to this Smart Device project's output directory (not to the original WinForms project's directory). This way, you have two separate projects with the same source files, that will compile to their respective target frameworks. Making edits in the files will show up in both projects. NOTE: If you open the files from the desktop project, you will get Intellisense for the full framework. If you open the files from the PDA project, you will get Intellisense for the Compact Framework. Even though it is exactly the same files, Visual Studio will determine which editing environment to use based on which project opened the files. ALSO: If you need code specific to either framework, define a symbol in your Compact Framework project properties that you can use for #if..#endif pragmas. This way you can add custom code for each framework that won't interfere with the compiled code in the other framework. For example: Say you define a symbol "NET_CF" in your Compact Framework project. In your code you can do something like this: #if NET_CF ... CF code... #else ... Desktop code... #endif Hope this helps
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
-
I had to do the same thing recently. :) Glad I could help :)
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee