Note: I am writing about ?Windows Mobile? as in ?based on Windows CE 5.x? rather than ?Windows Phones? as in ?based on Windows CE 6.x?.
Test-Driven Development
It came as a surprise to me ? a welcome one, to be sure, but a surprise all the same ? that there actually is a Unit Test framework for the .NET Compact Framework that is both easy to use and really runs on the .NET Compact Framework. It is called MsTest ? Unit Testing for .Net Compact Framework is now friendly enough! describes how to use it.
Debugging Unit Tests on .NET CF is said to be a pain (at least according to Debugging Smart Device MSTEST Unit Tests). My team and I are of the opinion however that if things come to the point where you need to debug a unit test, you are doing something wrong. So we decided to accept this problem.
There?s one pitfall there though. Every Smart Device project in Visual Studio has an associated target device. However, the unit tests do not run on the associated target device of the test projects. They run on the target device of the test configuration instead.
What?s with the Network?
Enabling network on a Windows Mobile Device is simply a matter of running the emulator, pointing to File ?> Configure on the emulator, clicking on the Network tab and making sure that the NE2000 checkbox is activated.
However, on Windows 7 you may receive the following error when you try to enable the checkbox and click on OK: ?The required Virtual Machine Network Driver could not be found. Make sure that Virtual PC 2007 is installed. You can install Virtual PC 2007 from http://go.microsoft.com/fwlink/?linkid=46859?.
This is a bit of a quandary: Virtual PC 2007 does not work on Windows 7, there is a separate ?Virtual PC for Window 7? (part of Windows XP Mode on Windows 7). In order to enable networking on the emulator, you need to install Virtual PC 2007. That results in Virtual PC for Windows 7 being broken (at least the network). So if you need Virtual PC on Windows 7, you need to uninstall Virtual PC 2007.
Fortunately, it is possible to install the network components of Virtual PC 2007 only, so you can have the best of both worlds: working network on the device emulator, and working Virtual PC on Windows 7. Windows Virtual PC and the Microsoft Device Emulator describes how to set this up.
ActiveSync, USB and DMA Connections
In order to connect a Windows Mobile device to your PC, you need ActiveSync on Windows XP and Windows Mobile Device Center on Windows Vista or 7. If you want to connect a Windows Mobile Emulator to your PC as well, you will need to allow DMA connections.
Once you have allowed DNA connections, you need to ?cradle? your emulator, using the Device Emulator Manager (%ProgramFiles%\Microsoft Device Emulator\1.0\dvcemumanager.exe). Your emulator will then behave exactly like a physical device connected to your PC.
/etc/hosts
Sooner or later during development of any non-trivial project there comes the need to match DNS names to IP addresses. In other words, you need a hosts file. Too bad that there is no hosts file on Windows Mobile.
As it turns out, you can achieve the same goal by using the registry of the mobile device, as described in /etc/hosts file equivalent in Windows Mobile device.
Remotely Controlling a Windows Mobile Device
It is much more comfortable to control a device by using the keyboard and mouse of your own PC than to use a stylus and tap around on small squares. Additionally, it comes in handy if you can copy text on your pc and paste it on the mobile device, or vice versa. MyMobiler is a freeware program that does exactly that; SOTI Pocket Controller is a commercial alternative.