views:

1945

answers:

3

I've been told there is an environment variable you can set to force .NET applications to run as 32bit applications on x64 versions of Windows. Do you know what it is, or know of a reference on it? I'm afraid my google-fu has failed me today (or it doesn't exist).

I'm using Resolver One (a .NET spreadsheet) and want to access some 32bit only functionality without modifying the executable. If I can configure this from an environment variable then I can access 32bit functionality when needed but also run as a 64bit app when needed.

(NOTE: effectively I want to be able to switch whether an application runs as 32bit or 64bit at launch time instead of forcing it at compile time.)

Thanks

+2  A: 

Check this: http://www.hanselman.com/blog/BackToBasics32bitAnd64bitConfusionAroundX86AndX64AndTheNETFrameworkAndCLR.aspx

target platform in project property dialog btw.

eglasius
No - that talks about setting 32bitness at compile time not at runtime. I have a .NET application that I *sometimes* want to run as a 32bit app.
fuzzyman
+6  A: 

How about this link

Not quite an environment variable, but just use the CoreFlags tool to switch back and forth.

To switch to 32 bit:

CorFlags.exe TheApp.exe /32BIT+

To go back to 64 bit:

CorFlags.exe TheApp.exe /32BIT-
Eric Petroelje
Hmmm... this is what I was trying to avoid, but may not have any choice - thanks.
fuzzyman
@Ruben - fixed my answer.
Eric Petroelje
@Eric: Great stuff; Removed my comment
Ruben Bartelink
+8  A: 

I've had an answer from Dino Veihland (Microsoft IronPython developer). I haven't had time to test it yet...

It's COMPLUS_ENABLE_64BIT. I think setting it to 0 disables 64-bit.

You should be able to set it as an env var or add a key to HKLM\Software\Microsoft.NETFramework with just the name "Enable_64Bit" to set it globally (this is how all the COMPlus_* vars work). This one might be special enough (it has to run before the process is created) that it has to be set in the reg key but I'm not entirely certain.

fuzzyman
The environment variable didn't work for me, but setting the registry entry and rebooting did.
fuzzyman
the registry setting worked for me too, thanks!
UserControl
Registry setting worked like a charm, thanks :)
Patrick Cuff