如何使 .NET 可执行文件在 64 位操作系统上作为 32 位进程运行?
我想让我的 .NET 应用程序作为 32 位进程在装有 .NET1.1 的 64 位计算机上运行。目标平台选项是在 VS(2005) 的更高版本中引入的,但我使用的是 VS2003 和 .NET1.1,并且没有机会使用其他 VS 或 .Net
这可能吗?
PS我不知道这是否相关,但我的一位同事说我应该使用“cor flags”或“core flags”,但谷歌搜索并没有得出任何有趣的结果
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以告诉 Windows 以 32 位运行应用程序。
尝试:
corflags myassemble.exe /32bit+
请参阅corflags.exe 实用程序的文档。
StackOverflow 此处有关于 CorFlags 的精彩总结。
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.
你不需要做任何事。 .NET 1.1 不支持在 64 位模式下运行托管代码。直到 .NET 2.0 才可用。任何使用 VS2003 编译的 EXE 程序集都会要求 1.1 版本的 CLR,它会自动以 32 位模式运行托管代码。
同样,您也不会拥有 Corflags.exe 实用程序。它最初随 .NET 2.0 SDK 一起提供,现在随 Windows SDK 一起提供。 Visual Studio 2005 及更高版本允许您通过在项目选项中选择“平台目标”来设置 Corflags.exe 操作的 cor 标头中的选项位。
请注意未安装 .NET 1.1 的 64 位计算机。他们将使用版本 2 CLR 运行您的应用程序,并且该应用程序将以 64 位模式运行。在 Vista 及更高版本中实现的 UAC 也会引起问题,您的 EXE 不会有清单,Windows 会将其视为遗留程序。当效果不佳时,很难诊断。 XP 以后的操作系统不支持 VS2003。有一个缺陷列表,大部分都是调试问题。顺便说一句,让您的工具根据客户的操作系统功能进行更新非常重要,对于狗年和软件工具来说,8 年是一个很长的时间。
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.
您可能需要手动使用编译器并指定目标平台:
http://msdn.microsoft.com/en-us/library/zekwfyz4(v=vs.80).aspx
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
难道不应该什么都不做就做吗? 1.1 仅为 32 位。如果 .NET 1.1 不存在,您的程序将使用现有版本运行,但框架可能足够智能,知道 1.1 应用程序只能在 32 位下运行。
否则,您可以尝试在计算机上安装 1.1,这样您的应用程序将与其绑定并且仅以 32 位运行。
http://technet.microsoft.com/en-us/ Library/cc785813(WS.10).aspx
这似乎证实了我的理论:
http://blogs.artinsoft.net/pdermody/archive/2005/04/07/153.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
在配置管理器中,您应该能够选择 x86 平台 - 我认为可以这样做,因为我想不出它还有什么用处。
编辑:哦,这是一个优化事情。该死,现在我的名誉永远不会有整数了......
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...