Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment variable to force .NET applications to run as 32bit

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

like image 406
fuzzyman Avatar asked Mar 06 '09 15:03

fuzzyman


People also ask

How do I force a program to run in 32-bit mode?

Drop the application "corflags.exe" into the \windows\system32 folder. Open a command line as administrator and type... This will force the application to run as a 32-bit process instead of 64-bit. This edits the executable file though.

What is the special environment where a 32-bit application runs on a 64-bit system?

WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows. This allows for 32-bit (x86) Windows applications to run seamlessly in 64-bit (x64) Windows, as well as for 32-bit (x86) and 32-bit (ARM) Windows applications to run seamlessly in 64-bit (ARM64) Windows.

Can a 32-bit application launch a 64-bit application?

The 64-bit versions of Windows don't provide support for 16-bit binaries or 32-bit drivers. Programs that depend on 16-bit binaries or 32-bit drivers can't run on the 64-bit versions of Windows unless the program manufacturer provides an update for the program.

How do I set environment variables in Visual Studio?

In Visual Studio 2019 right-click your project, choose Properties . In the project properties window, select the Debug tab. Then, under Environment variables change the value of your environment from Development to Production or other environments.


2 Answers

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 value to HKLM\Software\Microsoft\.NETFramework with the name "Enable_64Bit", the type REG_DWORD and the value 0 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.

like image 159
fuzzyman Avatar answered Oct 15 '22 23:10

fuzzyman


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- 
like image 30
Eric Petroelje Avatar answered Oct 15 '22 23:10

Eric Petroelje