Simon Green's Developer Blog
Developing .NET in the cold white north ...

Running .NET Apps in 32-bit mode on 64-bit Windows

Monday, 17 December 2007 12:37 by Simon

The normal behavior for .NET 2.0 applications compiled with the default 'Any CPU' platform is to run as 32-bit on x86 (32-bit) Windows and as 64-bit on x64 (64-bit) Windows.

Occasionally, some apps won't run correctly - I've recently run into this with CCNetConfig (a CruiseControl.NET Configuration tool) and have seen it before with other tools. Another obscure scenario where it shows up is if you try to use the JET OleDB driver which will fail in 64-bit mode because there isn't one! (it has to be 32-bit).

Rather than have to recompile the app or even worse, run a 32-bit Virtual Machine, there is an easy way to force .NET to run an app in 32-bit mode using the 'CorFlags.exe' tool.

Depending on your system this may be installed in different places. I've seen it in different places on XP64 and Vista X64:

  • C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\x64\CorFlags.exe
  • C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\CorFlags.exe

Running this from the command line with the path / filename of the app you want to change and the switch /32BIT+ to turn on 32-bit mode, e.g.:

   CoreFlags.exe TheApp.exe /32BIT+ 

If that fixes the problem then you know that it is a 64-bit issue. You can re-enable 64-bit operation for the app by turning off the 32-bit switch with the parameter /32BIT-, e.g.:

   CoreFlags.exe TheApp.exe /32BIT- 

Voila ... control over 32-bit and 64-bit execution without doing a recompile! I'm not 100% certain but I think that this switch sets the same flag that the 'x86' and 'Any CPU' targets set in Visual Studio.

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:   , ,
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

September 5. 2008 03:43