Emulator 101

This is perhaps a newbie topic, but I have seen people use the emulator wrong (IMO), so today I’ll write about the basics regarding the emulator in Visual Studio 2005.

Unfortunately support for Windows Mobile 5.0 devices wasn’t ready when Visual Studio 2005 was released. There was a quite stable beta (Magneto) available, but several things was changed for the final release.

So lets assume you have a clean install of Visual Studio.
Download and install the Windows Mobile 5.0 SDK. Also download and install ActiveSync. If all goes well you should have a couple of new project types in Visual Studio, e.g. Visual C#->Smartdevice->Windows Mobile 5.0 Pocket PC. If you start a new project like this, you have access to the emulator for testing.

I think it’s important how you think about the emulator. I think it is common to simply think of it as a test run-time, i.e. you start it each time you test your application, then close it when you’re done. A better way is to think of it as a real physical device that just happens to be located on your machine. That means you start it and then keep it running in the background. If you press the stop button in Visual Studio (when debugging) the application will stop, but the emulator will keep on running. In this way at least you save some time not having to start the emulator each time.

How to use it:
You should start the emulator through the Device Emulator Manager. Go to Tools->Device Emulator Manager…
This manager is a powerful, but not very user-friendly tool (to start, you have to scroll to get to the Windows Mobile emulators). Start the emulator by right-clicking on Windows Mobile 5.0 Pocket PC Emulator and select Connect. If the emulator has a black screen, it means that is booting – just wait it out. If this is the first time starting the emulator, it may be a good idea to set up any changes (e.g. network connections see below) now, and the just close it again – answering Yes to save the emulator state.

If you do this and then start the emulator again (you might have to click the Refresh button on the DE Manager), you’ll see that it starts much quicker (with any changes you made). This is of course because of the saved state is just loaded in again exactly as it where.

One real neat thing about the emulator is that it is an exact copy of the real thing. So if you don’t have a real device you can play around with it to see how it’s like. If you mess it up, just don’t save the state when you close the emulator, and everything is back to normal (File->Clear Saved State (in emulator) if you accidentally save a messed up state).

If you start your program in Visual Studio (and select the Emulator in the dialog) it starts inside the emulator. An extremely cool thing is that you can set breakpoints and do remote debug against it (as you can do with a real device).

How to connect it to the Internet:
You have to use ActiveSync to do this. Make sure it is installed, then when the emulator is running – right click it in the Device Emulator Manager, and select Cradle. After a few seconds ActiveSync will pop-up after having noticed the new device. Just click cancel if ActiveSync wants to set up a profile for the device, and click Stop if it tries do synchronize. As you can see ActiveSync doesn’t know that it is an emulator, to it this is just another device connected to the PC via a cable.

You now have access to the emulators file-system either by clicking Explore in ActiveSync or selecting “Mobile Device” in Windows Explorer (under My Computer). Select My Windows Mobile-Based Device to go to the root of the device. The emulator should now be able to connect to the Internet through ActiveSync (make sure ActiveSync is not blocked by a firewall). Verify this by starting Internet Explorer in the emulator and click on the “Windows Mobile” logo (picture).

Tip: If you get the cannot connect error, go to Settings->Connections->Advanced. Then click Select network and select My work network in the topmost dropdown (so that both have this selected). Then click OK in top right corner twice. Back in IE try clicking on the logo now – usually that does the trick

Advertisements

4 Responses to Emulator 101

  1. Tryst says:

    Great article, but its worth noting that the DMA setting must be selected in the ‘File->Connection Settings’ of ActiveSync for this to work. When COM1 was selected, I could not get the Emulator to connect through ActiveSync.

  2. trnilse says:

    Thanks for your comment Tryst, I actually had that problem myself recently when re-installing my machine. I had forgotten about that setting, so the cradle function just wouldn’t work 🙂

    Funny that the device manager doesn’t give any error or warnings – it says ‘cradled’ but nothing happens.

  3. gracias por crear programas como este

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: