Sedat Kapanoglu
Sedat Kapanoglu

Reputation: 47640

How to make a .NET executable run on 64-bit framework

I have an executable that defaults to 32-bit. It doesn't have source code and I want to keep both 32-bit and 64-bit frameworks on the system. Is there a way to make that executable run on 64-bit .NET framework instead?

Upvotes: 3

Views: 6918

Answers (5)

ShuggyCoUk
ShuggyCoUk

Reputation: 36438

use the corflags tool to flip the '64 bit is okay if available' flag

This blog post explains this with examples and some further links.

If you have the source code recompiling with anything VS 2005 and over will allow you to change the settings to make it willing to run as 64 bit.

Upvotes: 5

Dave Van den Eynde
Dave Van den Eynde

Reputation: 17405

Scott Hanselman recently blogged about this.

Writing managed code is a pretty good way to not have to worry about any x86 (32-bit) vs. x64 (64-bit) details. Write managed code, compile, and it'll work everywhere.

So in effect, if you build it for "Any CPU", it should run in 64-bit mode on a 64-bit OS automatically. But you can only do that if all the code is managed. You should read the blog entry for details.

Upvotes: 0

lowglider
lowglider

Reputation: 1087

If the executable is written in .NET and is all managed code there should be no problem running it under 64bit. The .Net-Framework for x64 comes with CLRs for both 32bit and 64bit code.

Consider reading this blogpost by Scott Hanselman, it covers the issue:

Back to Basics: 32-bit and 64-bit confusion around x86 and x64 and the .NET Framework and CLR

Upvotes: 1

Alexander
Alexander

Reputation: 3744

If you application needs to run on both 32-bit and 64-bit systems, a good way is to configure the compiler to force the binary running in 32-bit mode. This will force any 64-bit system to run your application in a 32-bit emulation mode. (Project properties -> Build -> Target Platform -> "x86" instead of "Any CPU")

Otherwise you have to provide two binary versions of your application: a 32-bit binary and a 64-bit binary.

Upvotes: 0

Peter
Peter

Reputation: 38455

Do you have the source code or just the Exe?

If you have the source code you could just compile it to 64 bit, if you dont you could use reflector do get the source code and recompile it to 64 bit.

Upvotes: 0

Related Questions