Monday, 7 February 2011

How to deploy to, and debug, multiple instances of the Windows Phone 7 emulator

I’m developing a multi-player Windows Phone 7 game. Now I don’t know about you, but I find it hard to test a multi-player application when I’m only allowed to run one instance of it. And that seemed to be the case with Windows Phone 7 applications. Microsoft provide an Emulator, but it’s a single-instance application: however many times you click its icon, you only get the one window.

Googling found me a useful article on how to run multiple instances of the emulator. But it didn’t tell me how to deploy applications to them, or how to debug those applications. There was however, a post in the forums, somewhat reminiscent of Monsieur de Fermat scribbling's, that gave me hope that what I wanted to do was indeed possible.

So I set out on a journey of discovery.

About an hour later, I had this,imagethis, imageand thisMultiple Instances

Step by Step instructions

Disclaimer: what I am about to show is completely unsupported by Microsoft or me. Continue at your own risk. Here be dragons.

  1. Open the folder [Your Drive Letter]:\ProgramData\Microsoft\Phone Tools\CoreCon\10.0\addons
  2. Locate the file ImageConfig.en-US.xsl
  3. Take a copy of it, leaving it in the same directory, and name it something like ImageConfig.en-US 2nd Instance.xsl
  4. Open the copy in your text editor of choice.
  5. Locate the element DEVICEDEVICEElement
  6. Change the Name attribute, and assign a new value to ID – you can use the Online Guid Generator if you can’t think of one off the top of your head.
  7. Scroll down the file to locate the part that says PROPERTY ID=”VMID”:VIMD
  8. Put a new Guid inside that element – make sure though that you use capital letters rather than lower case.
  9. Save the file
  10. That’s it. Re open the XAP deployment tool, or Visual Studio, if you already have them open, and you’ll see your new Emulator instances.

A Bonus Visual Studio tip

To debug multiple instances of your Windows Phone 7 application you can do the following:

  1. Start the first instance as usual.
  2. Change the Deployment Device to your newly-minted 2nd Emulator: image
  3. To start the 2nd instance, right-click on your project, go to the Debug menu item, then select Start new instance:image

4. Prepare a wet towel and a darkened room in preparation for the multi-player debugging experience.

13 comments:

Matt Lacey said...

May be useful to others to note that I had to edit the copy of the XSL file as Administrator for the changes to be recognised.

Anonymous said...

I get the feeling that this is huge! you'll make a lot of people happy :)

Bogdan Tănăsoiu said...

 +1 to HappyPeople

oran kaplan said...

thx allot!!

Rainbow said...

Thanks a lot. Very useful.
Carry on...

Nilp said...

I can't change target device while debuging first instance and XNA Game Studio Deployment device is always grayed.
I've tried to run 2 instance of Visual Studio with copy of project, but the applications don't work together (don't see)

Rachie said...

Fantastic! Thanks very much :D

Miles said...

I have the same problem, the combo box is grayed and I can't change target device (step 2.). Have you solved it?

Den said...

The same issue, how to resolve?

Nathan Sokalski said...

This is definitely a great step forward, I've been getting really tired of continuously plugging and unplugging cables every time I change a line of code. However, even though I can get two instances of the app running now, they still don't seem to communicate like they do when I run them on actual devices. The technology/classes that my code uses is sockets and UdpAnySourceMulticastClient. I was looking at the ImageConfig.en-US.xsl file, and noticed the following line:

7000

I found this interesting, since they emulator is able to run apps for 7.1. Other things I noticed in the file said 7.1, so I'm guessing that this is not the problem, but until I figure out how to test my apps using them, having multiple emulator instances still doesn't help. But this is definitely a step forward regardless (and it will still probably be helpful at some point for apps that don't use sockets anyway)!

Shawn said...

Hello Sam ... you can add another 1 to the happy list. :) Thank you for this great post.

markus.skergeth said...

Hi! I am facing exactly the same issue with Windows Phone 8 (on Windows 8). Unfortunately, these steps don't work for Windows 8/Visual Studio 2012 :(
Does anybody have a suggestion on how to solve this?

Agent007 said...

This is super cool, thank you very much ! :)

Post a Comment