nishantv
nishantv

Reputation: 781

Running a 32 bit .NET application on 64 bit machine

I have an application with projects having Platform as Any CPU. when run the application on 64 bit machine(win7) in VS2008 I can see in task manager process with *32 which means its running in 32 bit mode. But I have read that applications with Platform as Any CPU run according to the machine(64 bit in my case) . I am all confused. Please explain.

Upvotes: 0

Views: 2646

Answers (3)

Martin Liversage
Martin Liversage

Reputation: 106796

Are you sure that the project that creates the actual executable is set to AnyCPU and not x86? This project as well as all the referenced projects should be set to AnyCPU. If you do that the process will run as a 64 bit process on 64 bit Windows (and as a 32 bit process on 32 bit Windows).

It is the platform target for the .EXE project that determines the "bitness" of the application. If any referenced .DLL project has a "bitness" that is incompatible with the "bitness" of the running application you will get a runtime error. E.g. if an AnyCPU .EXE project references a x86 .DLL project it will succesfully run on 32 bit Windows but fail with a runtime error on 64 bit Windows.


The question is about Visual Studio 2008 but Visual Studio 2012 with .NET 4.5 introduced the anycpu32bitpreferred setting:

anycpu32bitpreferred compiles your assembly to run on any platform. Your application runs in 32-bit mode on systems that support both 64-bit and 32-bit applications. You can specify this option only for projects that target the .NET Framework 4.5.

Turning this setting on (the default in Visual Studio) means that AnyCPU applications will execute as 32 bit even on a 64 bit operating system.

Upvotes: 2

Mayur Gondaliya
Mayur Gondaliya

Reputation: 73

  1. Go to Build => Configuration Manager
  2. Click Active Solution Platform dropdown list and select .
  3. In Type or select the new platform dropdown list, select 'x64'.
  4. Hit OK.

Upvotes: 0

Thorsten Dittmar
Thorsten Dittmar

Reputation: 56697

As VS2008 is 32 bit I would expect it to launch a 32 bit process as well. Another reason could be you're referencing 32-bit only DLLs?

Have you tried running the application outside VS2008 - is it still in 32 bit mode?

Upvotes: 1

Related Questions