I have a project which generates a 32-bit executable. This executable is included as part of a bigger package where the executable is installed as a Windows service using MSI installer. Even though the executable is 32-bit (I examined the file header), the process is running as a 64-bit process. I was trying to debug this process and when I opened the "Attach Process" menu through Visual Studio, I saw its type included x64 instead of x86.
Is this possible or am I missing something? If it is possible, how can I do this for some other 32 bit executable?
CodePudding user response:
For .NET executables, that's normal. .NET executables run in whatever environment suits best, depending on the available hardware and runtime version. It is possible to force executing a .NET executable in 32 bit mode, but that is usually only done when it needs to interact with a 32 bit native dll.
Details differ a bit between .NET Framework assemblies and .NET Core/NET5.0 assemblies. But for the later, it's basically that the target runtime specifies whether it runs the binary in 32 bit or 64 bit mode. That's now easy, since the application is almost always built in "AnyCPU" mode, telling the runtime that the application doesn't care what CPU is used (or what operating system, hardware, etc.)