Monday, December 13, 2010

Developing for Windows Phone 7 in a virtual machine

According to Microsoft, installing the windows phone developer tools into a virtual machine is not supported. This is because the phone emulator is itself a virtual machine and, as Inception has shown, running a virtual machine inside a virtual machine gets really slow. The emulator also requires DirectX 10 for XNA develoment, and current virtual machines only offer DirectX9.

However I do all my development in virtual machines. I already have a VM setup with VS2010, version control, database etc. I don't fancy setting that up all over again just for a phone, particularly one that I only have for 2 weeks.

Time to do some testing...

Virtual PC
Running the dev tools in a Windows 7 Virtual PC works (or rather fails to work) as advertised. While I could create and compile a phone project, I couldn't actually run it in the emulator.

VMWare
Using a VMware vm was much better. I could compile and run a silverlight project on the emulator. On my laptop, the emulator performance was dire. On my desktop however, emulator performance was adequate but not stunning.

On either machine, XNA projects wouldn't run on the emulator due to the lack of DirectX 10. They would compile but trying to deploy would fail with "The current display adapter does not meet the emulator requirements to run XNA Framework applications."

However deploying and running on a real phone worked fine. Both Silverlight and XNA deployed and ran without any issues.

Booting from a virtual hard drive (thanks Paul)
Should work but requires Windows 7. See here.

TL;DR
You can develop Silverlight applications in a VMWare virtual machine, testing against the emulator (slow) or actual hardware (fast). You can develop XNA applications in a VMWare vm but you need to deploy to actual hardware.

Useful links
Microsoft's free tools: Create App hub
Charles Petzold giant ebook: Programming Windows Phone 7
Reddit Win Phone 7 section: http://www.reddit.com/r/wp7dev/

5 comments:

Anonymous said...

Please share a Silverlight sample app on Windows Phone 7 :-)

Unknown said...

You have very similar experience now that I had when developing Compact Framework apps a couple of years ago:

Emulator does not work in Virtual PC

Emulator does work on VMware.

That was the time I fully switched to VMware for software development.

--jeroen

Paul Johnson said...

I'm curious if you could get around this by booting the VM as your primary disk. Windows 7 supports this, and Scott Hanselman has a blog post about doing it. http://www.hanselman.com/blog/LessVirtualMoreMachineWindows7AndTheMagicOfBootToVHD.aspx

Sean said...

@Rick
I am still learning Silverlight so I don't have much in the way of sample apps to show. I will add some usefull links to the post though.

Sean said...

@Paul
Doh, I forgot to mention that. Booting from a virtual disk as per Scotts post should work fine.