简体   繁体   中英

What determines if a .NET app that targets the "AnyCpu" platform runs at 32 or 64 bits?

I have a .NET solution with several .NET Framework projects inside, two of which generate executables (one is a Windows Service, the other is a WPF app).

Both of those projects target the "Any CPU" platform and do NOT have the "prefer 32bit" flag switched on in the build options.

However, I noticed through the task manager that while the WPF app starts by default in 64bit mode, the service starts in 32bit mode instead.

My question is: why the difference? What determines if a .NET executable that doesn't target a specific platform starts in 32 or 64 bit mode? Is it because it is a Windows Service specifically?

EDIT: re-opening, because the linked supposed "duplicate" question doesn't actually explain why a service would start in 32bit mode on a 64bit machine.

Thanks to @canton7 for pointing me in the right direction.

Turns out that the "prefer 32bit" flag was still active, even if I disabled it from visual studio. Probably a caching issue, I closed visual studio, deleted the bin folders, reopened and rebuilt the solution, the service now correctly starts in 64bit mode.

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