Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating 64-bit applications

If I have a 32-bit application written in C#, what do I need to do to convert it 64-bit? I'm assuming its more complicated then simply changing the target machine to 64-bit in Visual Studio and recompiling.

like image 285
Icemanind Avatar asked May 01 '26 03:05

Icemanind


2 Answers

If you don’t use interop (COM, WinAPI) and don’t make assumptions about the size of pointers it’s a straightforward switch to the other platform. Even when using the latter you are probably fine, unless you use libraries that somewhere make above mentioned assumptions.

To quote the MSDN concerning System.IntPtr:

The IntPtr type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems.

– But the other .NET types are designed to have a fixed size, regardless of the platform.

like image 183
Konrad Rudolph Avatar answered May 03 '26 15:05

Konrad Rudolph


Do you actually need it to be running in 64 bit or do you just want it to run on a 64 bit machine?

In the case of the latter you can set the C# project to target Win32, rather than AnyCPU. This means when you run it on a 64 bit machine it will run through WOW (32 bit "emulation") this has the advantage that the (unmanaged) JET driver will also run 32 bit. This should solve your problem.

like image 39
Ade Miller Avatar answered May 03 '26 17:05

Ade Miller