BrianPeek.com
A Compendium of Random Uselessness
Install the Surface SDK on Windows 7 and/or x64

image

Update: Running Surface SDK SP1?  See my other post on how to install it on a 64-bit machine...

The Microsoft Surface SDK was given out to some folks at PDC 2008.  I know the 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"

3-10-2009 4-40-54 AM

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.

3-10-2009 4-57-13 AM

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.

3-10-2009 5-05-50 AM

Update 12/4/09: If you have problem with the Identity Tag printer not bringing up the printer dialog box, modify the above command to add the /UpgradeCLRHeader switch.  Thanks to Klaus Amtoft for this tip!

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:

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

3-10-2009 5-17-51 AM

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!


Posted Tue, Mar 10 2009 5:31 AM by Brian Peek
Filed under: , ,

Comments

Josh Santangelo wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Mar 10 2009 1:52 PM

Brian, you are my hero. I just set up a whole new machine with Vista 64, and the very last thing I had to install was the Surface SDK. I about cried when it wouldn't install. I managed to figure out the Orca trick, but that's as far as I got. These instructions totally worked for me, and I'm very glad I don't have to rebuild my system in order to work on our next Surface project. If you're going to MIX, and you run into Darren David from Stimulant, he owes you drinks.

Chris Miller wrote re: Install the Surface SDK on Windows 7 and/or x64
on Sat, Mar 14 2009 9:48 AM

If you want to get Orca without having to download the 250MB Platform SDK, there are a few places where you can just grab the Orca bits.

Aaron Stebner posted a copy on his blog at blogs.msdn.com/.../180792.aspx

Brent Norris posted a copy on his blog at www.brentnorris.net/.../319

Daniel Siegl wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Apr 28 2009 9:34 AM

thanx for the helpfull post. - I use InstEd to edit msi's

Jmix90 wrote re: Install the Surface SDK on Windows 7 and/or x64
on Mon, May 18 2009 2:44 PM

Hello,

Thx for the article... but I still have a problem : When I run the samples from visual studio, there is no errors but when I launch them from the simulator they crash as soon as I click somewhere in the app (it seems to be well launched)...

Do you have a clue ?

Steven wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, May 21 2009 8:11 AM

Hi :)

When I try to patch my samples after I edited the InstallSamples.bat I have this error :

corflags : error CF001 : Could not open file for writin

Any idea why ?

Thank you :)

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, May 21 2009 1:01 PM

@Steven, are you running in an elevated cmd prompt?

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Sun, May 31 2009 8:01 PM

@Jmix90, it sounds like the simulator and/or the built samples aren't properly patched to force 32bit. I've seen this exact behavior when the two don't match...the sample apps crash and behave pretty badly.  Can you verify that the simulator and tools are patched along with the output sample exes?

Joshua wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jul 23 2009 4:52 PM

Hi,

I am having the same issue as Steven (and actually similar results to Jmix90), I can run the simulator (under vista 64) but I can't patch any of the samples and any that I run from within the simulator crash when I click after they load.  Any suggestions would be appreciated.

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jul 23 2009 4:54 PM

@Joshua, same questions to you....

Are you running the patching commands from an elevated command prompt?

And, have you built the samples an then patched all executables that have been built?

Joshua wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jul 23 2009 4:58 PM

Brian,

Yes running from an administrator command prompt (and had no issues patching anything besides the samples0

built all the samples, but I haven't been able to patch the executables (corflags : error CF001 Could not open file for writing)

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jul 23 2009 5:02 PM

@Joshua, I'm going to sound like a broken record.  :)  The only time I've ever seen corflags fail with that error is when it's not being run from an elevated command prompt.  Is there any other information attached to the corflags error?  Can you copy/paste a bit of the output from the cmd window here?  Or to a forum post?  Or email to me? (click the Contact Me link above).  Thanks!

Joshua wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jul 23 2009 5:11 PM

Brian

Here is an ouput from trying to patch the samples

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

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

ngCart\obj\Release\ShoppingCart.exe" /32bit+ /force

Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.21022.8

Copyright (c) Microsoft Corporation.  All rights reserved.

corflags : error CF001 : Could not open file for writing

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

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

ualizerEvents\bin\Release\TagVisualizerEvents.exe" /32bit+ /force

Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.21022.8

Copyright (c) Microsoft Corporation.  All rights reserved.

corflags : error CF001 : Could not open file for writing

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

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

ualizerEvents\obj\Release\TagVisualizerEvents.exe" /32bit+ /force

Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.21022.8

Copyright (c) Microsoft Corporation.  All rights reserved.

corflags : error CF001 : Could not open file for writing

I am definitely running this from a command prompt run as an admin (and have even tried disabling uac to see if that has any impact)

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jul 23 2009 5:20 PM

@Joshua, the only other thing I can think of is to ensure your user has Full Access to the SDKSamples directory and everything below it.  I'm not sure what else to try...I've never been able to reproduce this.  Just tried again on my Surface samples directory and it's working just fine...

Joshua wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jul 23 2009 5:30 PM

I checked the permissions and everything is set to Full Access so I am somewhat at a loss, is there any-chance you could just provide a zip with all of the patched exe's (seems to be about 5 megs worth of exes in the sample directory)?  

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Fri, Jul 24 2009 1:25 AM

@Joshua, contact me directly using the Contact Me link above.

Ariel wrote re: Install the Surface SDK on Windows 7 and/or x64
on Sat, Aug 8 2009 9:39 PM

Trying to run corflag on the specific EXEs after the simulator was reconfigured and I'm running into the same errors that others are mentioning.

: error CF001 : Could not open file for writing.

Browsing directly to the directory, I'm finding the files to not even be in the v1.0 directory.

Verified that folders & files aren't being hidden.  I'd SO very much rather not go through a full reinstallation of the OS just to downgrade to 32bit

Ariel wrote re: Install the Surface SDK on Windows 7 and/or x64
on Sat, Aug 8 2009 9:41 PM

Never mind - I am just being blind / not paying attention.

Ty for posting the information !

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Sat, Aug 8 2009 9:49 PM

@Ariel, what was the problem?

James wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Aug 13 2009 7:21 PM

The problem you guys are having is that you aren't right clicking on the command prompt and saying "Run as administrator"

I was getting the same problem (corflags : error CF001 : Could not open file for writing.)

Once I ran the CMD as administrator the problem went away.

BLACK BLOG wrote Installer le SDK Surface sur Windows 7 - 64 bit
on Tue, Sep 29 2009 6:00 PM

Installer le SDK Surface sur Windows 7 - 64 bit

Jmix90 wrote re: Install the Surface SDK on Windows 7 and/or x64
on Wed, Oct 7 2009 4:17 PM

I still have the same problem than Joshua !!!

Running as elevated account...

I don't understand !

Jmix90 wrote re: Install the Surface SDK on Windows 7 and/or x64
on Sun, Oct 11 2009 1:23 PM

on solution is to set x86 for all the projects in VS and compile them all ...

Chris Nicol wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Nov 24 2009 4:05 PM

I have a different problem to those above.  In the Surface/v1.0 ... I seem to be missing the list of exe's you iterate through.  The SDK installed properly, but yet these are missing.  I can run the simulator, but it crashes.  I'm running Win 7 64bit.

Thanks

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Nov 24 2009 4:08 PM

@Chris, those are the files required to run the simulator.  They basically are the simulator and its dependencies.  Are you sure you had a successful install?  What's in that directory if you open it in Explorer?

Chris Nicol wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Nov 24 2009 4:14 PM

I'm running a repair on the installation as we speak (type), but as far as I can tell it ran the installation fine.

In that directory I have the following:

11/24/2009  11:57 AM    <DIR>          .

11/24/2009  11:57 AM    <DIR>          ..

11/24/2009  11:56 AM    <DIR>          da

11/24/2009  11:56 AM    <DIR>          de

11/24/2009  11:57 AM    <DIR>          Doc

11/24/2009  11:56 AM    <DIR>          en

11/24/2009  11:56 AM    <DIR>          es

03/18/2009  10:20 PM           177,458 EULA_da-DK.rtf

03/18/2009  10:20 PM           184,307 EULA_de-DE.rtf

03/18/2009  10:20 PM           187,755 EULA_en-US.rtf

03/18/2009  10:20 PM           230,232 EULA_es-ES.rtf

03/18/2009  10:20 PM           198,320 EULA_fr-FR.rtf

03/18/2009  10:20 PM           201,608 EULA_it-IT.rtf

03/18/2009  10:20 PM           649,844 EULA_ko-KR.rtf

03/18/2009  10:20 PM           220,206 EULA_nb-NO.rtf

03/18/2009  10:20 PM           173,803 EULA_nl-NL.rtf

03/18/2009  10:20 PM           180,499 EULA_sv-SE.rtf

11/24/2009  11:56 AM    <DIR>          fr

03/18/2009  03:54 PM             4,392 GettingHelp.htm

11/24/2009  11:56 AM    <DIR>          it

11/24/2009  11:57 AM    <DIR>          Item Templates

11/24/2009  11:56 AM    <DIR>          ko

11/24/2009  11:56 AM    <DIR>          nl

11/24/2009  11:56 AM    <DIR>          no

11/24/2009  11:57 AM    <DIR>          Project Templates

11/24/2009  11:57 AM    <DIR>          Reference Assemblies

11/24/2009  01:00 PM    <DIR>          Samples

11/24/2009  11:56 AM    <DIR>          sv

11/24/2009  11:57 AM    <DIR>          Tools

             11 File(s)      2,408,424 bytes

             18 Dir(s)  189,292,531,712 bytes free

c:\Program Files (x86)\Microsoft SDKs\Surface\v1.0>

The repair ran "successfully", but still no exe's.  I have the workstation edition of Surface SDK 1.0 SP1 ... encase that makes a difference.

Thanks

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Nov 24 2009 4:16 PM

@Chris, that's a very different directory structure than mine.  Where did you get the installer?  Perhaps they've changed something...

Chris Nicol wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Nov 24 2009 4:18 PM

If I post my IM can you remove it ... perhaps it would be quicker to chat across IM ... if you don't mind?

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Nov 24 2009 4:20 PM

@Chris, send me an email.  Use the "Contact me" link above or brian@ this domain

Chris Nicol wrote re: Install the Surface SDK on Windows 7 and/or x64
on Tue, Nov 24 2009 4:25 PM

To answer your question for anyone reading this thread.  I'm using the "Microsoft Surface SDK 1.0 SP1, Workstation Edition"  downloaded from the community.surface.com/downloads ... under "Develop"

Klaus Amtoft wrote re: Install the Surface SDK on Windows 7 and/or x64
on Fri, Dec 4 2009 4:21 AM

FYI

Had problems with the Identity Tag printing tool (even after settings the 32bit flag.. wouldn't open the printer dialog. I fixed this by running corflags with upgradeclrheader option:

C:\Program Files (x86)\Microsoft SDKs\Surface\v1.0\Tools\GenTag>for %i in (*.exe

) do corflags %i /UpgradeCLRHeader /force

Still trying to solve the "corflags : error CF001 : Could not open file for writing"-error: Iam running it in an elevated prompt, but still receives the error:P

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Fri, Dec 4 2009 4:31 AM

@Klaus, thanks for the info.  I'll update the post.  If you manage to get anywhere with the writing error, please let me know.  I've still be unable to reproduce it on any machine I've ever installed the Surface SDK on.

Klaus Amtoft wrote re: Install the Surface SDK on Windows 7 and/or x64
on Fri, Dec 4 2009 4:38 AM

To resolve the writing error, i "cheated";) I copied the contents of the samples folder to a folder on my desktop, ran the corflags on the exe's and copied the entire content back, and now it works;)

I could have rebuild the solution with the options set for each project, but this seemed easier;)

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Dec 24 2009 11:59 PM

Wow.  I just finally got the "Could not open file for writing error".  The answer: copy/pasting the line from my blog produces the crazy Unicode rounded quotation marks, not the real " mark.  So, type it in by hand or be sure to replace the " marks by typing them!  I'll update the post...

Stian Farstad wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jan 28 2010 6:09 PM

Hey thanks for this nice article.

When installing the sdk on win7 x64 it all goes well almost to then end, then the installer starts to roll back and uninstall itself. Is there any error log to find?

Is it required to have vs sp1 installed? I'm using vs2k8 pro with the winsdk7. Some of the lines in the msi differs from the ones in the post.

Installed OR (VersionNT=600 AND ServicePackLevel>=1) OR VersionNT>600

Installed OR VISTASKU<>"Starter"

I also have vs2k5 installed on my system, as this is my favorite ide & compiler. If I remember correctly after installing vs2k8 sp1, the x64 platform gets removed.

Best regards,

Stian Farstad

Brian Peek wrote re: Install the Surface SDK on Windows 7 and/or x64
on Thu, Jan 28 2010 6:17 PM

@Stian, it sounds like you're using the Surface SDK SP1, which is the current version.  Check the link at the very top of this article to the new post with information on how to patch that version.  As for VS SP1, it is listed in the requirements...I don't know if it will work without it.

Stian Farstad wrote re: Install the Surface SDK on Windows 7 and/or x64
on Fri, Jan 29 2010 12:06 PM

Cheers! Your other post solved the issue :)

Add a Comment

(required)  
(optional)
(required)  
Remember Me?