强制 .Net Windows 服务在 64 位机器上作为 32 位运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1079066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:57:49  来源:igfitidea点击:

Forcing a .Net Windows service to run as 32-bit on a 64-bit machine

.netconfiguration64-bit

提问by Steve Cooper

I've been given a windows service which references a COM component that only runs on 32-bit. My machine is x64, so the service tries to start, fails to create the COM component, and dies.

我得到了一个 Windows 服务,它引用了一个仅在 32 位上运行的 COM 组件。我的机器是 x64,所以服务尝试启动,无法创建 COM 组件,然后死了。

I don't have the source, just the .exe file. Is there any way to force a service to start in 32-bit mode on a win64 machine?

我没有源,只有 .exe 文件。有没有办法强制服务在 win64 机器上以 32 位模式启动?

回答by Thomas Freudenberg

Maybe the .NET tool corflagswill help:

也许 .NET 工具corflags会有所帮助:

corflags /32bit+ myservice.exe

corflags /32bit+ myservice.exe

回答by David B

corflags.exe comes with the Windows SDK, not .NET.

corflags.exe 附带 Windows SDK,而不是 .NET。

corflags.exe needs to run only once against the target service exe. Then the service will run in 32-bit mode thereafter.

corflags.exe 只需要针对目标服务 exe 运行一次。然后该服务将在此后以 32 位模式运行。

Note the argument needed is /32bitreq+ or /32bitpref+ .

请注意,所需的参数是 /32bitreq+ 或 /32bitpref+ 。

corflags.exe /32bitreq+ myservice.exe

corflags.exe /32bitreq+ myservice.exe