64-Bit – How Hard Can It Be?

If you do programming in .NET world answer is clear: It is not hard at all. As long as you keep your hands out of cookie jar (know also as Win32), moving to 64-bit is just none to few clicks away.

Of course, some prerequisites are needed.

You need to have 64-bit operating system

This is pretty obvious - 32-bit operating system on 64-bit hardware will work in 32-bit mode. No big surprise here.

You need to work on .NET framework 2.0 and above

.NET framework 1.0 and 1.1 exist in 32-bit versions only. They will run on 64-bit platforms without any problem but they will do so through emulation layer called WOW64 and thus no support for 64-bit address space - everything above 2 GB stays unavailable.

You need to tell your favorite .NET compiler that you want that

By default, .NET will compile code for target platform called "Any CPU". Although one could think that this would make code that is common denominator of all - 32-bit, it will actually mark executable as both 32-bit and 64-bit. This is possible since code is translated to CLR and thus processor agnostic. On 32-bit systems it will run as 32-bit code, on 64-bit systems it will run as 64-bit code. In case that you need insane amounts of memory (for me insane is above 2 GB) all the times, you can select x64 or Itanium as your target and make your code unable to run in 32-bit mode at all.

If you use installer let him know about your bit-ness also.

If you pack your code with MSI installer, you have a problem. There is no way to tell it that your code is both 32-bit and 64-bit (Any CPU).

If you select x86 as your platform, it will install correctly on both 32-bit and 64-bit Windows but on 64-bit it will install in Program Files (x86) folder. That folder is reserved for legacy 32-bit code and having your application there sends clear signal to users that something is wrong here althought it will run as 64-bit application when you start it.

If you select x64 or Itanium as your target platform you will end up with installer that will show error message and refuse to proceed if system is 32-bit (or that other 64-bit one) even though code would run just fine.

There are two solutions. Either make separate MSI package for every platform or switch installer. Neither of these two is nice one. :(

Leave a Reply

Your email address will not be published. Required fields are marked *