DCSIMG
Running on Windows Phone 7 Emulator or real Device - Essential WPF

Running on Windows Phone 7 Emulator or real Device

In one of the labs I’m writing for the Windows Phone Training Kit I’m using kind of GPS Emulator for simulating a geographic location (Latitude, Longitude). This simulator comes in handy when writing location aware application, and you don’t really have a GPS on the emulator. So instead of using C# pragmas for picking the correct path, knowing whether the application is running on a real device or not, there is an easy static property for checking that:

if (Microsoft.Devices.Environment.DeviceType ==
    Microsoft.Devices.DeviceType.Emulator)
{
   
MessageBox.Show("Running on Emulator"
);
}

else
{
   
MessageBox.Show("Running on Device");
}

Opening Microsoft.Phone.dll using reflector is seams like the:

Microsoft.Devices.Environment.DeviceType is always DeviceType.Emulator.

image

Yea, that is suspicious. It looks like the phone device itself has different assemblies.

But this works fine on my WP7 device.

Enjoy using the Emulator, but don’t forget to test your application on a real device…

Published Wednesday, November 17, 2010 11:52 AM by Tomer Shamam

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above:
Powered by Community Server (Commercial Edition), by Telligent Systems