When you build and run a Windows Mobile (ie .NET Compact Framework) application from with Visual Studio it does a number of things in the background. After building your application it has to deploy it out to the device or emulator that you want to run it on. It then of course has to attach to the remote process so that you can step through your code in the debugger.
One of the issues with using a single solution for building both Windows Mobile and desktop (or even web applications) is that when you do a build, by default, the Windows Mobile application will not only build, it will try to deploy to the device or emulator. This can add a few extra seconds to every build so it’s not something you want happening on every build.
Luckily there is a quick way to disable this functionality: Right-click on the solution node in Solution Explorer and select Configuration Manager. You will see that there is an additional column entitled Deploy and you’ll see that the mobile application has a check in this column. If you uncheck this your mobile application will not be deployed on each build.
There is one little gotcha here – if you are not careful you will experience a number of side effects:
- Build and run will NOT run the latest version of your mobile application. It will build it but because you have not told it to deploy your application it will run the last instance of your application to be deployed to the device.
- If this is the first time you are running your application there is no previous version of your application on the device, so you will see a prompt similar to the following:
Unable to start program ‘%CSIDL_PROGRAM_FILES%\MobileApp\MobileApp.exe’.
The system cannot find the file specified.
There are two ways to address this:
- You can force a deploy by right-clicking your mobile application project in Solution Explorer and selecting the Deploy option. Now when you run your application it will run the version you have just deployed.
- You can create different build configurations – one for doing destop development and debugging, and one for doing mobile development and debugging. In the former you can uncheck the build and deploy checkboxes for the mobile application. In the latter you need to check both the build and deploy checkboxes for the mobile applications (note: you don’t need to deploy mobile class libraries so long as they are referenced by the actual mobile application as they will automatically get deployed along with the application).

