开发者

How do you make a .NET executable run as a 32-bit process on a 64-bit OS?

开发者 https://www.devze.com 2023-02-17 08:19 出处:网络
I want to make my .NET application run as a 32-bit process on a 64-bit machine with .NET1.1. The target platform option was introduced in later versions of VS(2005), but I am using VS2003 and .NET1.1

I want to make my .NET application run as a 32-bit process on a 64-bit machine with .NET1.1. The target platform option was introduced in later versions of VS(2005), but I am using VS2003 and .NET1.1 and don't have an opportunity to use other VS or .Net

开发者_StackOverflow中文版

Is this possible?

P.S. I don't know if this is relevant, but a colleague of mine said I should use "cor flags" or "core flags" but googling it didn't come up with any interesting results


You can tell Windows to run an application as 32-bit.

Try: corflags myassembly.exe /32bit+

See the docs of the corflags.exe utility.

StackOverflow has an excellent summary of CorFlags here.


You don't have to do anything. .NET 1.1 doesn't have any support for running managed code in 64-bit mode. That didn't become available until .NET 2.0. Any EXE assembly compiled with VS2003 will ask for the 1.1 version of the CLR, it automatically runs managed code in 32-bit mode.

Similarly, you won't have the Corflags.exe utility either. It originally shipped with the .NET 2.0 SDK, nowadays with the Windows SDK. Visual Studio 2005 and up lets you set the option bit in the cor header that Corflags.exe manipulates by letting you select the "Platform target" in the project options.

Do watch out for 64-bit machines that don't have .NET 1.1 installed. They'll run your app with the version 2 CLR and that is going to run in 64-bit mode. UAC as implemented in Vista and up can also cause trouble, your EXE won't have a manifest and Windows is going to treat it like a legacy program. Which can be very hard to diagnose when that doesn't work out well. And VS2003 is unsupported on operating systems past XP. There is a defect list, most of them are debugging problems. Keeping your tools updated with your customer's operating system capabilities is rather important btw, 8 years is a long time in dog years and software tools.


You likely need to use the compiler manually and specify the target platform:

http://msdn.microsoft.com/en-us/library/zekwfyz4(v=vs.80).aspx


Shouldn't it do it without doing anything? 1.1 was 32 bits only. If the .NET 1.1 is not present your program will run with the version present, but perhaps the framework is intelligent enough to know that a 1.1 app can run only at 32 bits.

Otherwhise you can try to install 1.1 on the machine, so your app will be binded to it and will run only at 32 bits.

http://technet.microsoft.com/en-us/library/cc785813(WS.10).aspx

This seems to confirm my theory:

http://blogs.artinsoft.net/pdermody/archive/2005/04/07/153.aspx

Loading .NET 1.1 applications in Windows 64-bit

I was surprised to find - and you might be surprised to hear - that Microsoft decided not to allow even pure .NET applications that were built on 32-bit machines with certain versions of Visual Studio to run on the 64-bit CLR.


In the configuration manager you ought to be able to select the platform as x86 - which I presume does this, as I can't think of anything else it's good for.

Edit: Oh, so that's an optimization thing. Damnit, now I'll never have a round number for my reputation...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号