Installing CF2.0 on the emulator

July 13, 2006

It’s real weird, but the localized images for the Emulator doesn’t seem to have CF2.0 installed on them. I tried to install it by using the msi installer, but it told me I already had it installed and just stopped. What about people that have two Windows Mobile devices ? Shouldn’t you be able to install the device run-time anyway?

I suspect there must be an easier way to do this, but here is what I did:

  • Start the Emulator (from Device Emulator Manager), and connect it to ActiveSync (se earlier posts if you don’t know how)
  • Copy the file to the emulator (mine was located at %program files%\Visual Studio 2005\SmartDevices\SDK\CompactFramework\2.0\v2.0\WindowsCE\
  • In the emulator, use File Explorer and click on the cab file you copied – it should then install
  • This is real important: When the installation is finished, you’ll be asked if you want to reset the device. DO NOT CLICK ON OK!
  • Click Cancel. Then in the emulator select File->Reset->Soft
  • When the emulator has booted again, it may be a good time to save the state 🙂

When I clicked on OK after the installation, the emulator apparently did a hard reset. Yes, this means that all installed programs and settings was deleted, including the Compact Framework 2.0. 🙂

Emulator 101

July 12, 2006

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


July 11, 2006

Some cool news: .Net might be coming to the Symbian OS (Nokia, SonyEricsson etc.) !

Unfortunately it’s only the CF 1.0 (for Smartphones), however CF2.0 is sure to follow if it is a success!

(from Nino.Mobile)

Testing with localized versions of Windows Mobile

July 10, 2006

For testing purposes it is very useful to be able to run your program on different language versions of Windows Mobile. Luckily you don’t have to buy different physical devices, just change the OS image in the emulator.

To do this start by downloading the images (note: there are different images for smartphones). After downloading the MSI files simply install them as normal, and the new OS will appear in the Device List with the 3 letter abbreviation as a prefix.

Unfortunately it installs 8 different devices (items in the list) for each language, and if you plan to install a lot of different languages this can be annoying. Another way to change the OS is to simply use the image binary itself. The binary is located at <path where you installed the image>/Deviceemulation/0414/ the one you probably want is called PPC_xxx.bin (xxx = language code) (to get it – either extract it from the MSI or install, get the bin then uninstall the image).

Go to the options for the emulator and select the binary in the OS Image Name textbox. After restart (and clearing state!) you are set to go!

Setting the emulator’s available RAM

July 9, 2006

It is useful to be able to change the Device emulators available RAM, however if you select File->Configure… in the emulator you are not able to change the values!

The supposed reason for this is that Windows Mobile does not support changing/adding RAM on the fly (if you put more RAM into your physical device, you have to restart it to be able to use it).

To change it: In Visual Studio, select Tools->Options…, then select Device Tools->Devices (You can also click Device Options on the Device toolbar). Select Windows Mobile 5.0 Pocket PC Emulator in the list to the left, and click Properties. Then click Emulator Options.
If you check the “Specify RAM size” checkbox, you are able to change the RAM (remember to restart the emulator!).

There are also some other important options here, I’ll come back to them later.

A final gotcha – if you have saved the emulator state any changes to the RAM will not be applied. You have to clear the saved state (in the emulator: File->Clear Saved State) and reset the Emulator for it to update.

Missing error messages

July 7, 2006

When debugging against a physical device you may get this message when breaking on an exception:
“An error message cannot be displayed because an optional resource assembly containing it cannot be found”.

It’s extremely annoying because it doesn’t tell you what ‘optional resource’ that is missing. Luckily I found a clue on the Microsoft Forums (link).

If you get this message you should try to install the file “System_SR_ENU_wm.CAB” from the Mobile 5.0 SDK (mine was at %program files%\Visual Studio 2005\SmartDevices\SDK\CompactFramework\2.0\v2.0\
WindowsCE\Diagnostics ).

Note that the ENU parts corresponds to English-US so if you have set a different locale on your device (Start->Settings->System tab->Regional Settings) you should chose the corresponding .CAB file (if your locale don’t have a CAB hopefully the ENU will work, although I haven’t tried it).

Also note that the file can be uninstalled as a normal program (Start->Settings->System tab->Remove Programs).

What’s bugging me is that it seems like this problem suddenly appeared (i.e. I got error messages before), and I don’t know why. Ah, well – as long as it works…

Edit: Tip – if it doesn’t work, try changing your locale to the language you installed. (Settings->System tab->Regional Settings)

July 7, 2006