A .NET dll can be run as both 32 bit and 64 bit on a machine with an x64 processor. I need to determine at runtime what bitness my application is running under.
Currently I've been doing something like System.IntPtr.Size == 8
, but that seems like an ugly hack. Is there a more "correct" way of determining this?
In .NET 4 and beyond, including .NET Core, the System.Environment
class has two static properties: Is64BitOperatingSystem
and Is64BitProcess
. In earlier .NET versions you need to use the IntPtr
size approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With