Windows Virtual PC and the Microsoft Device Emulator

Windows 7 (as of RC1) now supports a pretty spiffy new feature known as Virtual Windows XP or Windows XP Mode based on what article you read.  At its core, it is a new version of the Virtual PC product, now named Windows Virtual PC, installed closer to the OS, combined with a Windows XP hard disk image which allow you to run legacy applications under Windows XP on your Windows 7 machine in a pretty seamless way.

If you install the Windows Virtual PC add-on to Windows 7, you must first uninstall Virtual PC 2007.  By doing that, you remove the special network driver that is also required to use the Microsoft Device Emulator on the network.  The device emulator is typically used for Smart Device development.

So the puzzle:  The Device Emulator doesn’t work with the new Windows Virtual PC driver, and you can’t install the old version of Virtual PC 2007 and expect the new Windows Virtual PC to keep working.  What to do?

The answer is to extract the Virtual PC 2007 network service drivers out of the MSI package and manually install them in Windows 7.  So far this has provided the expected result for me:  Windows Virtual PC runs happily, and the Device Emulator now connects to the network.  So how do we do this?  Thanks for asking.  Here is a step-by-step guide to make this go.  Note that this is very much a “works on my machine” experience.  If it burns your house down, don’t hold me responsible.  Note that you should have a valid and complete backup before attempting this on your machine just in case…

  • Download the Virtual PC 2007 SP1 installer executable
  • Open a cmd prompt, navigate to the setup executable, and run:
    • setup.exe /c
  • This will extract the executable to an MSI file at located in the %temp% directory
  • Change to the temp directory by running:
    • cd %temp%
  • In this directory, extract the MSI by running:
    • msiexec /a Virtual_PC_2007_Install.msi /qb TARGETDIR=c:\vpc
    • Of course, feel free to replace that directory with one of your choosing
  • This will extract the MSI file to c:\vpc (or the one you entered)
  • Open the Network and Sharing Center and select Change adapter settings
    adapter
  • Right-click the network adapter you have connected to the internet and select Properties
  • Click the Install… button
    install
  • Make sure Service is selected and click Add…
    type
  • Click Have Disk…
    disk
  • For x86 machines, navigate to:
    • C:\vpc\Program Files\Microsoft Virtual PC\Utility\VMNetSrv\
  • For x64 machines, navigate to:
    • C:\vpc\Program Files\Microsoft Virtual PC\Utility\VMNetSrv\x64
  • Select Virtual Machine Network Service and click OK
    vmns

At this point the driver will be installed and attached to that network adapter.  If you have the need to attach this to multiple adapters, simply repeat the steps above to install the service on each adapter required.

Once the driver is installed, you can then link the Device Emulator to the chosen adapter and connect to the network as always, as well as connect to the network in the new version of Virtual PC.

Let me know how it works for you!



Site Upgrade and New Theme!

After finally finding a Community Server 2008.5 SP1 compatible theme I liked, I was able to upgrade my site to the latest Community Server version.  This theme is provided by Andrew Belon, who has several fantastic CS themes available on his site.  I’ve tweaked his basic Bliss theme (which he uses as his main theme) to my liking.

I’m a big fan of the new colors and layout, and I hope those reading this are as well.  I’ll continue to tweak over the coming days to make things a bit cleaner.

If you have any comments on the new site or you see anything out of place, please contact me and let me know…thanks!

Install the Surface SDK on Windows 7 and/or x64

image The Microsoft Surface SDK was given out to some folks at PDC 2008.  I know SDK is not out to the masses yet, however one of the questions/requests posted most frequently in the Surface forums is the ability to install the SDK on a 64-bit machine, and/or on Windows 7.  I’ve put together a quick guide that will show how to accomplish this.  But be warned…by doing this you are throwing away support from Microsoft.  This is an entirely unsupported setup and the Microsoft Surface folks won’t be able to help you.  So, if official support is important to you, this guide isn’t for you.  With that said, let’s continue…

Please note that you will still need to have Visual Studio 2008 Express or greater installed, and you will need to have the XNA 2.0 Framework runtime installed.

To perform the actions in this guide you will need to install Orca, a tool for editing MSI files, included with the Windows SDK.  Unfortunately, this utility isn’t available separately and will require you to download the full SDK to get it.  You can download the Windows Vista or Windows 7 SDK here.

1) Remove the platform checks from the MSI

Open the SurfaceSDKWE.msi file in Orca.  Select LaunchCondition from the left pane.  In the right pane, individually select the rows highlighted in the screenshot below, right-click, and select Drop Row.  This will remove the checks for 64-bit, Windows Vista, and Windows Vista SP1.  The rows are:

  • Installed OR (VersionNT=600 AND ServicePackLevel>=1)
  • Installed OR NOT VersionNT64
  • Installed OR VISTASKU="Business" OR VISTASKU="Ultimate" OR VISTASKU="Enterprise"

image

After the rows are dropped, save the MSI using the standard File –> Save menu option.

2) Install the SDK

Now that the MSI has been edited to remove the checks, install the SDK normally.

If you are using Windows 7 x86, you are done!  If you are running on an 64-bit OS, please continue…

3) Patch the executables

Now that the SDK is installed, several executables need to be patched to be forced to run inside the 32-bit CLR instead of the 64-bit CLR.  This will be done using the corflags.exe utility.  If you have the full Visual Studio installed, simply open an elevated Visual Studio Command Prompt from the Start Menu and the path to corflags.exe will automatically be loaded.  Otherwise, you should find this in the C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin directory and you can set your PATH environment variable appropriately.

With the path to corflags.exe in your PATH environment variable, change to the following directory:

C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Tools\Simulator

Inside this directory, run the following command:

corflags SurfaceSimulator.exe /32bit+ /force

You will get a warning that the file is strong named signed.  You can safely ignore this.

captured_Image.png[4]

Next, change to the following directory:

C:\Program Files (x86)\Microsoft Surface\v1.0

There are several executable to be patched in this directory.  You can easily do this from a single command as follows:

for %i in (*.exe) do corflags %i /32bit+ /force

This will enumerate all .exe files and patch them as done above.  You will again see the warning, and again, it can be safely ignored.

<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="captured_Image.pngDevil” border=”0″ alt=”captured_Image.pngDevil” src=”http://www.brianpeek.com/blogimages/InstalltheSurfaceSDKonWindows7andorx64_3EDA/captured_Image.png6_thumb.png” width=”588″ height=”484″ />

If you don’t care about running the sample applications, you are finished.  If you want to install and run the samples in the simulator, continue.

4) Build and fix the samples

The samples, by default, are setup to build as “Any CPU” executables.  This means they will always run under the 64-bit CLR, which is a problem.  They need to be built to run in the 32-bit CLR.  There are two ways to handle this: 1) you can edit each .csproj file to create an x86 build type and build the project, or 2) you can build the projects as-is, and patch them later.  I find option 2 to be easiest, so that’s what will be described here.  Note that you won’t be able to run and debug these samples via Visual Studio by doing this…if this is required, please go with option 1.

Unzip the Surface Code Samples.zip file from the C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Samples directory.  This should output a SDKSamples directory.  In this directory, open the InstallSamples.bat file in Notepad.  You will see several lines that check the registry for various things.  Each one of these will path the registry in a way similar to the following:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Surface\v1.0 /v IsLogicalSurfaceUnit

Modify each of these to add the Wow6432Node key, which is part of the 64-bit registry that 32-bit applications access:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Surface\v1.0 /v IsLogicalSurfaceUnit

It’s probably easiest to do a find and replace, finding SOFTWARE\Microsoft and replacing with SOFTWARE\Wow6432Node\Microsoft.

Next, run the InstallSamples.bat file.  This will build each sample and deploy them to the Microsoft Surface Simulator.

Now we need to patch the built executables.  Back in the elevated Visual Studio Command Prompt, change to the directory where you unzipped the sample SDKs.  For me, this path is:

C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Samples\SDKSamples

Run the following command to enumerate all directories and patch the executables:

<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="captured_Image.pngMusic” border=”0″ alt=”captured_Image.pngMusic” src=”http://www.brianpeek.com/blogimages/InstalltheSurfaceSDKonWindows7andorx64_3EDA/captured_Image.png8_thumb.png” width=”597″ height=”480″ />

Each file will be patched to run in the 32-bit CLR only.

That’s it!  You should now be able to build, run and debug applications using Visual Studio and the Microsoft Surface SDK on Windows 7 and Windows Vista, either x86 or x64.

Just remember…this is a totally unsupported scenario, so run at your own risk!

Coding4Fun Book Contest Winner!

imageIt’s time to announce the winner of my contest to win a copy of our Coding4Fun book!  15 people entered the contest via my forum.  I assigned each of them a 0-based index in the order in which they submitted their entry.  The final list was:

  • leif902 = 0
  • jcauble = 1
  • krakerjak = 2
  • RoryBecker = 3
  • amrkamel = 4
  • anonymous = 5
  • Arrowofdarkness = 6
  • qiuliocc = 7
  • hanan = 8
  • Amira = 9
  • helpware = 10
  • michaelb = 11
  • FunnyX = 12
  • John Bisschop = 13
  • juanformoso = 14
  • bringo = 15

Now, I did say you had to sign up using a valid user account, but the anonymous person linked to their blog which had contact info, so I decided to allow their entry in the mix….

To pick the winner, I wrote up a single line snippet in the ever-popular Snippet Compiler, pressed F5, and the result was…

captured_Image.png

That’s number 11, which indexes to michaelb and his winning post!  Thanks to everyone that entered for their support and kind words!

Mix09 Wiimote/C4F Meetup?

MIX09LogoAt the very last minute, I was lucky enough to receive a free ticket to Mix09 (thanks Jay!) and have decided to attend to attend.  After posting about it on Twitter, Matthias Shapiro suggested that since both Johnny Lee and I will be there (Johnny’s giving a session on the Wiimote), perhaps we should have a Wiimote “hacker” get-together.  I think it would be great to get all Wiimote fans, and even fans of the Coding4Fun website/book together to put names with faces and have some fun.

Sooooo….

I’ve put together a very quick, 3-question survey to gauge interest in having a meetup and what you’d like to do.  If you’ll be attending Mix and are interested, please take the 30 seconds to fill out the survey.  I’ll move forward with the plan based on the reaction of people going.  There’s no sense in putting it all together for 2 people to show up.  :)

Thanks!

Win a Free Copy of Our Coding4Fun Book!

image I’ve decided to setup a simple contest to give away a free copy of our book, Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More.  Entering is simple.  Post a message to the forum entry located at:

http://www.brianpeek.com/forums/p/1012/3258.aspx

And to make it a bit more interesting, here’s a topic for your post:  How have you coded for fun?  Write up a couple sentences on any fun project you’ve tackled at some point in your spare time.  I won’t disqualify you if you don’t, but I’d love to hear about your projects, and I’m sure others would too.

Make sure you are registered on this site with a valid email address and are logged into your account so I have a way to get in touch with you if you are the winner.

Entries must be received by Saturday, February 29th at 11:59pm EST.  One person will be randomly selected and contacted shortly thereafter and I will send them a copy of the book, free of charge.  That’s it…good luck!

Brian and Dan on .NET Rocks!

image This week, Dan Fernandez and I had the opportunity to be on the .NET Rocks! show with Richard and Carl.  We spent some time chatting about our Coding4Fun book (available at fine booksellers everywhere!) and several extremely interesting projects Richard and Carl have created in the past, including an anthromoporphic remote-controlled car, and a parrot who enjoys extremely right-wing politics.  I think you’ll just need to listen to the show to understand what those are about…

Virtual Earth 3D Beta Documentation Released

image If you’ve followed any of my Virtual Earth 3D projects, you know that the managed API has been undocumented and unsupported for a while.  All the work that has been done so far has been possible due to a few VE3D team members posting information on their blogs and through reverse engineering using tools like Reflector.

Well, half of the problem has been solved:  The VE3D team has now released beta documentation for the VE3D GlobeControl !  As their blog post states, it’s still beta and not officially supported, but it’s definitely a great a start.

Now to see what assumptions I made in my projects that are incorrect…