Reputation:
We developed a C# application using the .NET Framework 2.0 which works fine in 32-bit computers. But when I run my application in a 64-bit environment, it crashes.
I need to make my application to run in 64-bit environment.
How do I do this?
Upvotes: 7
Views: 28785
Reputation:
Is it Windows/ASP.NET application?
If it is an ASP.NET application. you can run only 32/64-bit modes at the same time. For doing this,
Case 1. you need to Enable32bitApplication
on the application pool in the IIS.
Then reset the IIS.
Case 2. Check for the corresponding DLL in regedit.
If it is windows based, run this command from Visual Studio prompt,
CorFlags.exe TheApp.exe /32BIT+ //Enables 32 bit application.
Upvotes: 0
Reputation: 21467
Just expanding on Fredrik Leijon's answer above, I think this is what you are after.
It will tell both 64 and 32 bit windows to run your application on the 32 bit environment.
Remeber to do the same for your 'Release' configuration.
This will in turn update your *.csproj file for MSBuild to pick up as follows (check the <PlatformTarget/>
element below):
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
Upvotes: 2
Reputation: 41
Here is what looks to be a nice solution if you are looking to avoid recompilation. Note it does require a change to each target machine.
If you have a 64 bit machine and want to run a .NET application that only works with the 32 bit CLR you would have to make changes to the .NET framework on your machine
Set the .NET framework to load the CLR in WOW mode through this command
Open up command prompt and type this command
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe SetWow
Now you should be able to run apps that use only the .NET 32 bit CLR.
To revert back to the default 64 bit framework run
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe Set64
(source)
Upvotes: 4
Reputation: 105
If you are on Windows you shall use CorFlags Conversion Tool (CorFlags.exe). This way you might enforce application/dll's to run in 32/64 bit space. Details and examples of use are available at http://msdn.microsoft.com/en-us/library/ms164699(VS.80).aspx.
Upvotes: 6
Reputation: 35544
I faced the same problem. I my case it was enough to compile the main assembly (.exe) of my application especially for "x86". The other assemblies (.dll) are compiled with "Any CPU".
Our application then works fine on 32Bit and 64Bit systems.
Upvotes: 1
Reputation: 2802
You could compile it for x86 instead of any cpu that way it will run against 32bit librarys on a 64bit windows.
Or swap 32bit librarys for 64bit when installning on 64bit windows. Among other some Sqlite dlls are specific for 32/64 bit
Upvotes: 9
Reputation: 106826
In the build settings for you project set the platform target to x86 instead of Any CPU. This will solve problems where your project has "hidden" dependendencies on 32 bit subsystems that are not available in 64 bit. Your application will then run in the 32 bit susbsystem on 64 bit Windows.
Upvotes: 4
Reputation: 33445
It should just run unless you're referencing libraries that are specifically only available for 32bit (Jet DB drivers are one example) or unless you've told your compiler to compile your application to 32bit only.
What does the crash say?
Upvotes: 0