Freigeben über


What the Hyper-V? WP8 SDK Emulator and Hyper-V Insights

As I noted in an earlier post [  https://blogs.msdn.com/b/devfish/archive/2012/11/06/are-you-slat-compatible-wp8-sdk-tip-01.aspx ], the Windows Phone 8 emulator requires Hyper-V if you wish to work against the emulator.  So what’s going on under the hood?  Let’s take a peek at some of the Hyper-V points going on with Windows 8 and Hyper-V.

The Windows Phone 8 SDK ships with four different emulator images –  512meg memory constrained WVGA , a 1024 meg WVGA, 1024 WXGA, and 1024meg 720p. There is a ‘base’ image for each, preconfigured, and ready to be deployed. The base emulator mages themselves can be found in C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Emulation\Images

image

Hyper-V must be installed somewhere to make this work.  Let’s take a look at the Hyper-V control area.  On the Windows 8 Start Screen, simply type in “Hyper-V” and you will see an entry for the Hyper-V Manager in the list of programs.  Click on the icon to bring up the Hyper-V Manager.  Once the Hyper-V manager starts, a list of virtual machines present on the machine you are on will be presented, along with a variety of control options.  If you haven’t used Visual Studio to run any WP8 programs to the emulator (or manually configured any other virtual machines), the Hyper-V Manager will show a blank, empty surface in the list of VMs.

When you deploy a Windows Phone 8 program to one of the emulator, a number of things will happen.  Firstly, Visual Studio will check to see if an instance of the emulator matching your target is already provisioned.  If there is no image for the target deployment present, Visual Studio will deploy and provision the appropriate emulator image to Hyper-V.  Below you can see the Hyper-V Manager after just one emulator image has been used.  As you can see the emulator virtual machine is provisioned, and ready to go.

hyperv-afterfirstrun

 

The .vhd will be copied from the SDK directory to the user’s AppData directory.   The Phone SDK tools will run off the copy of the image.  On my machine the image wound up in C:\Users\Joe\AppData\Local\Microsoft\XDE\dd.480x800.512.vhd .  You can see this by going into the emulator settings for the image, and navigating over to the Name property.   In the info displayed will be the location of the .vhd in use for that emulator image.  Settings like memory amount and network adapter configuration will be added to the initial deploy.

image

If you deploy a program using each of the emulator targets in Visual Studio, a separate virtual machine will be created for each in Hyper-V.  Walking though each vritual machine you might notice that all are configured for 1024 meg of ram.  The exception to this would be the 512meg WVGA image.  Also note if you go into network settings, all are configured for a Network Adapter of “Windows Phone Emulator Internal Switch”, which allows for the phone emulator to act on the same network as the users machine.

512-memory1024-memory

Power tip: I know some folks in our FLADEV  group are working on games and chat clients to be used against other players in a real time fashion.  Programming and debugging these scenarios can be difficult as you cannot have two instances of the same emulator running on the same machine.  If you try and run two instance of the same emulator using Visual Studio you will get an error similar as shown below.

no-two-same-emus

But….  If you start once instance of Visual Studio, and deploy to say the “512 WVGA Image”, then start another instance of Visual Studio and deploy to the “720p Image” you will be successful.  You could use this configuration to simultaneously run and debug multi-client instances of the phone emulator.  Below you can see four instances of the emulator image running at the same time, from four separate Visual Studio 2012 instances.

fouremulators

Hyper-V also has all four emulator images ready to go at this point as well.  In the image below you can see all four, turned off, but at a state where the startup will be very fast as the provisioning and setup is complete.

hyperv-allup

 

Note this was possible in Visual Studio 2010 using the 7.1.1 SDK and a similar trick [ https://blogs.msdn.com/b/devfish/archive/2012/03/15/7-1-1-windows-phone-sdk-tech-preview-two-emulators-at-once.aspx  ]. 

Power Tip : If you think your emulator image has gone “wonky”, delete it from Hyper-V when its not running.  The next time you run to that image from Visual Studio 2012 it will re-provision Hyper-V.

Got any more tips ?  Let me know in the comments below.  The use of Hyper-V for the emulator might open up some interesting scenarios re snapshots, base lining an image, or other scenarios.. 

MORE INFO

Comments

  • Anonymous
    November 27, 2012
    Thanks for this Joe! So, what about when the OS the WP8 SDK is running on is itself a guest in a Hyper-V environment? How do I install the SDK on the Hyper-V host so that I can still debug my apps? Is there a way to be able to redirect the network calls to a different IP?

  • Anonymous
    November 27, 2012
    my laptop is too old (core 2 duo) to run the wp8 emulator. So i have to stick to wp7 app development. I wonder how many developers are in the same situation

  • Anonymous
    November 27, 2012
    @imperial... I'm sure there's a few.  Good news is OS7.1 aka Windows Phone 7.5 apps will run on WP8.  I personally advocate folks targeting first 7.5 to get the biggest distribution, then 8.0 for the light up features.  You can still produce great stuff for Windows Phone 8 using the VS2010 and the OS7.1.1 tools.

  • Anonymous
    November 27, 2012
    out of curiosity .. does Win8 development and its emulator also use a similar hyper-v approach for emulating different devices and specs? just curious cause I like the WP8 approach and would love the Win8 team to use it too if they arnt already!

  • Anonymous
    January 02, 2013
    Great article on saving the emulator state - sviluppomobile.blogspot.it/.../saving-windows-phone-8-emulator-state.html .  Enjoy...

  • Anonymous
    January 22, 2013
    Interesting topic Joe. I have installed the SDK 7.8 on Windows 2008 Server R2. The old emulator is running fine after all Hyper-V machines have been stopped. However the new emulator for 7.8 is just reporting that there is another instance of the emulator running with different credentials. After that the emulator is unresponsive and needs to be closed. Of course all machines have been stopped and in the Hyper-V manager I can see that no new machine for 7.8 has been created. I assume that this is caused by stricter security settings in the Server OS. Is there something I can adjust to overcome this issue? I know that the Server OS is not supported but this only seems to be a small problem with the configuration.

  • Anonymous
    January 22, 2013
    @Tron - 7.8 doesn't use hyperv.  I haven't worked much with the tools on server 2012 so I can't help there.  I would take the query to stackoverflow's windows phone group.  windowsphone.stackexchange.com