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

.net, c#, windows

Solution

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.

Problem

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: 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?

Original source