Mark Worrall
Mark Worrall

Reputation: 331

Building C# for Windows 7 32 bit platform on Windows 7 64 bit machine

Whats the correct way to build the setup installers for a Windows Forms app to install and run on a Windows 7 32 bit machine, using Visual Studio 2010 on a Windows 7 64 bit machine ?

I've just brushed the dust off a 3yr old Visual Studio 2008 app, built on Windows XP, using SQL Express 2005.

I've updated it to VS2010, SQL Express 2008, and rebuilt it on a Windows 7 64 bit machine. It needs to run on a Windows 7 32 bit platform.

The setup project for database keeps failing (on startup) when run, saying its only for an x64 machine. (The setup for the app runs ok and installs.)

I've been through every project in the solution and set it to build using x86 (as opposed to Any CPU). I've removed all PreRequisites. The only thing suspect left in there is a DB CustomAction project (which runs the db scripts).

From googling it seems to me building on a 64 bit machine with 'Any CPU', means it should produce setup files that will run on a 32 bit machine via WOW ? and without having to make all the changes Ive been making ? Am I missing something bleedingly obvious ?

Thanks.

Upvotes: 1

Views: 5358

Answers (2)

Mark Worrall
Mark Worrall

Reputation: 331

I always find it frustrating coming across posts of the same question I have that never had a resolution posted. So I'll post what I found in case it, or even some if it, is of use to others one day. I found a lot of other developers reporting the aimless Windows 7 program 'has stopped working' message.

By the way, I found the easiest way to test deploying the app and the installers was to build a Virtual PC machine with the same configuration as the platform will eventually run on. Then copy that Virtual PC, and test run on the copy. That way, I can just delete the copy at any time, recopy from the original and start over, quickly.

Yes, as Cosmin said, the TargetPlatform Property of the solution also needs setting to x86. Anyway, didnt fix the the problem, the app still produced the 'has stopped working' message.

Next I checked the SQL logs ERRORLOG file (c:\Program Files\Microsoft SQL Server\MSSQL10.SQLExpress\MSSQL\Log) and it was reporting the app was trying to logon using Mixed Mode authentication, whereas SQL was set for Windows Authenication. Now I KNOW I selected Mixed mode when I installed SQL Express, as my app uses a sql service account which my db installer creates the account for. So somehow that was changed by something (dont know what?). To set to Mixed mode via SQL Server Management Studio you just right click on the instance, select Security, and change Server Authentication. Without Management Studio, you need to edit the registry HKEY_LOCAL_MACHINE/Software/Microsoft/Microsoft SQL Server//MSSQLServer, and edit key LoginMode = 2 for Mixed. Once again, didnt fix the problem, the app still produced the 'has stopped working' message.

Next, by chance I stumbled across some posts about this message can be caused during startup by loading 32 bit apps on Windows 7. I put MessageBoxes, and Try/Catchs on the first lines I could, and they never got displayed, and no error was caught.

The next thing I tried was to run DependencyWalker over my exe. It reported 2 x 32 bit files missing: IEShims.dll and GPSVC.dll. There are posts from other devs encountering this, and the end result was I found them in C:\Windows\winsxs (GPSVC.dll was called x86_microsoft-windows-g..licy-base.resources_31bf3856ad364e35_6.1.7600.16385_en-us_c10af1bed239c523_gpsvc.dll.mui_0c160ac2). I dropped them into C:\Windows\System32, recompiled my app, deployed it to my test machine, and it finally ran !

Still dont understand why just putting them into the System32 dir on my dev box made the app run on the test machine ? But anyway, it fixed the problem, and hope this is of help to others.

Upvotes: 1

Cosmin
Cosmin

Reputation: 21416

Try this:

  • select your setup project in Solution Explorer
  • go to its Properties pane
  • make sure that TargetPlatform is set to x86

Upvotes: 1

Related Questions