简体   繁体   中英

Why are my .NET processes running as 32 bit when using the 64 bit installutil?

We have a C# console application that we have installed as a Windows service. The target 64 bit machine is running Windows Server 2012. We used the 64 bit installutil utility:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>installutil -i C:\Services\MainService\Service.exe

However when I see the process running in the Task Manager, it shows it running as 32 bit process:

Snapshot_of_task_manager_32bit_process

Any ideas why this is, and how I can get the process to run as 64 bit?

I saw this question posted here, but no one has answered it yet:

Why is my 64 bit service running as 32 bit?

What I ended up doing was using CorFlags.exe to remove the 32BITPREF flag from the EXEs. I just setup a build step in TeamCity to cover this:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\"CorFlags.exe Service.exe /nologo /32BITPREF-

I think the better approach would be to manually go through every project and disable that flag. As someone mentioned, a simple grep and sed would most likely do the trick.


Update

Clearing the "Prefer 32 Bit" flag is a better option. This ensures that 64 bit version is compiled, and no need for custom script in the TeamCity build configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM