Dual Project for Cross Platform Development
One of the topics that was covered in the show with Jeff Arnett is how you can aid cross platform development by using dual, or parallel, projects. The premise is that for every desktop project, you have a parallel device project. The projects reside in the same directory and use the same code files, which means that if you write code that will not compile on either the desktop or device it will display design-time errors in Visual Studio.
This seems a great idea in theory but the difficulty is trying to (a) get these projects setup and (b) maintaining them. The hardest thing with Visual Studio is overriding its default behaviour. For example when you create a new project, it will ALWAYS create a new directory to put it in. Further, if you try and create a project in an existing directory Visual Studio will prevent you. So, how do you setup two projects in the same directory? I will attempt to show you how you can get started.
Project Creation
- Open VS2005 and create a new Class Library project - Visual Basic –> Windows –> Class Library (for this example I will use a VB.NET project but this method works just as well in C#). Give the project the name “MobileLibrary”; create a directory for the solution; name the solution “Mobility”
- Add a new device Class Library project to the existing solution - Visual Basic –> Smart Device –> Windows Mobile 5.0 Pocket PC –> Class Library (again I have chosed WM5 PPC but this should work for any of the smart device project types). Give the project the name “MobileLibrary_CF”
- Exclude the device project from the solution
- Using File Explorer move the device project files (in this case “MobileLibrary_CF.vbproj” and “MobileLibrary_CF.vbproj.user” into the same folder as the desktop class library (in this case in the “MobileLibrary” folder)
- Add the device project into the existing solution (in this case from the “MobileLibrary” folder)
- You will probaby have 2 build errors relating to incompatibilities between the desktop and the device (AssemblyFileVersion and CompilerGeneratedAttribute are not supported on the device). You can safetly remove these lines of code and hey presto you’re done!
Now you will have to agree this is a bit of a PITA if you have to do this process every time you want to create a new class library in an existing solution. One way to get around this would be to create a multi-project template. However, again you run into the issue where Visual Studio will not allow 2 projects to be created in the same directory….




