如何强制服务的位数

问题描述:

我有几个 C# Windows 服务.一个人坚持以 64 位进程运行.

I have several C# Windows service. One insists on running as a 64 bit process.

这不是问题,只是我将所有共享配置迁移到 C:WindowsMicrosoft.NETFrameworkv4.0.30319Config

This wouldn't be a problem except that I migrated all shared configuration, to C:WindowsMicrosoft.NETFrameworkv4.0.30319Config

因此该服务无法读取配置,目前我不得不复制共享配置(这使将其移动到 machine.config 的意义不大)

As a result the service fails to read the config, and for the moment I am having to duplicate the shared configuration (which defeats the point of moving it to machine.config)

我已将构建配置从 x64 更改为 x86,并重新安装,但该服务仍以 64 位模式运行.

I have changed the build configuration from x64 to x86, and re-installed but the service still runs in 64 bit mode.

Execute Corflags/+32Bit [Service.Exe](.Net SDK 的一部分),它将通知操作系统该程序集必须以 32 位模式加载.

Execute Corflags /+32Bit [Service.Exe] (part of the .Net SDK) which will notify the OS that this assembly must be loaded in 32 bit mode.