tags:

views:

1592

answers:

3
+2  Q: 

C# for 64bit OS?

How can I make my compilation optimized for Windows 64 bit?

+4  A: 

A managed project is automatically built according to the architecture selected => default C# project created on AMD64 will be AMD64, X86 on X86. The native one is always 32-bit by default.

To explicitly set a platform:

1 open the solution explorer, select solution, right click->Configuration Manager.

2 go to 'Active Solution Platform', click New.

3 in the 'New Solution Platform' dialog that comes up select the new platform say Itanium. Set 'Copy Settings From' to 'Any CPU' which was the default setting in the 'Active Solution Platform'.

4 click OK.

This is from WebLog

Daok
+3  A: 

As Daok said, with a little addition.

Beware if you have third party DLL which uses Interop and is compiled with 32 bit. In that case, you will specifically have to set all your assemblies which uses it to use x86 or all manner of weird things will happen.

mannu
+6  A: 

You might also want to do a check at runtime, just to be sure:

using System;
using System.Runtime.InteropServices;

class SystemChecker
{
    static bool Is64Bit
    {
        get { return Marshal.SizeOf(typeof(IntPtr)) == 8; }
    }
}
TimothyP