Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if my program is running in 32 bit mode on a 64bit machine, if running in 64bit - how do I force it to be 32bit

We have a windows service created in .NET 2.0. I've set the Platform Target to X86, and the installer to be X86. The projects it references are set to ANYCPU.

We're running this on a 64bit server. It has to be 32bit because the ODBC drivers it accesses are 32bit, and they bomb heavily if accessed from a 64bit application.

I've seen that on a 64bit machine, some processes have the *32 beside them to denote 32bit, however that doesn't seem to be the case with a test one I created that specifically targets 32bit (X86) to see if it actually was that. The service we're running does not show *32 beside the service name.

Any thoughts on this? If it is not being run as 32 bit (X86), then I'm surprised as I've forced the build to be that.


Update, We found it's running in 64bit, even though the Services project was forced to buid in X86 mode. What would cause this?

like image 366
Ryan Ternier Avatar asked Dec 04 '25 19:12

Ryan Ternier


1 Answers

You can use IntPtr.Size (MSDN docs). This will return 4 if running as 32 bit and 8 if running as 64 bit.

like image 106
Jeffrey Sax Avatar answered Dec 06 '25 09:12

Jeffrey Sax



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!