2

is it Possible to Run a EXE witch is compiled as ANYCPU on an 64 BIT OS, but in 32bit Mode?

is there a way to configure the start mode?

thank you for any advice

Cajon
  • 53
  • 1
  • 4

2 Answers2

1

It is possible if you have compiled your app using the NET Framework 4.5. In this environment you can select the Prefer 32 bit to force your app to run in 32 bit mode also when the underlying OS is 64bit

Prefer 32 bit

This is the relevant part of this article:

In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default for most .NET projects is again AnyCPU, but there is more than one meaning to AnyCPU now. There is an additional sub-type of AnyCPU, “Any CPU 32-bit preferred”, which is the new default (overall, there are now five options for the /platform C# compiler switch: x86, Itanium, x64, anycpu, and anycpu32bitpreferred). When using that flavor of AnyCPU, the semantics are the following:

  • If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
  • If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
  • If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code.
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Steve
  • 213,761
  • 22
  • 232
  • 286
  • 1
    I want that the application run in 64bit mode if possible. Just on that one Machine it should run in 32bit. The Machine has a 64bit os – Cajon Feb 20 '14 at 15:09
  • It is an all or nothing option sorry – Steve Feb 20 '14 at 15:11
  • The link offered by [HansPassant](http://stackoverflow.com/users/17034/hans-passant) above could be your answer, however, I really suggest to read this article http://blogs.msdn.com/b/rmbyers/archive/2009/06/09/anycpu-exes-are-usually-more-trouble-then-they-re-worth.aspx – Steve Feb 20 '14 at 15:13
0

Yes !!

JIT will take care of this when you say 'AnyCPU', It will load 64-bit libraries when it is loaded into a 64 bit process or 32-bit when it is loaded into a 32-bit process.

Since you haven't specified which version of visual studio are you using, You can edit your project file manually for forcing your app to run on32 bit.

<Reference Include="Filename, ..., processorArchitecture=x86">
  <HintPath>C:\..\x86\DLL</HintPath>
</Reference>

and change Platform value in required areas.

<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
   <Reference ...>....</Reference>
</ItemGroup>
Community
  • 1
  • 1
Venkatesh K
  • 4,364
  • 4
  • 18
  • 26
  • 1
    Right, but if you run a .exe program as-is, it will still load in 64-bit mode on a 64-bit Windows. – helrich Feb 20 '14 at 14:59