Wednesday, July 25, 2012

Running under 32 bit or 64 .Net environment

In pure .Net code one probably does not need to know. But when linking to legacy native DLLs one may need to know. The following is an easy test. A pointer is 8 bytes in a 64 bit world and 4 bytes when in 32 bit:

C:\projects\generaldynamics\vbnet\ConsoleApplication6\ConsoleApplication6\bin>type ..\Program.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace ConsoleApplication6

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.Out.WriteLine("{0}", IntPtr.Size);

        }

    }

}

C:\projects\generaldynamics\vbnet\ConsoleApplication6\ConsoleApplication6\bin>x64\Release\ConsoleApplication6.exe

8

 

C:\projects\generaldynamics\vbnet\ConsoleApplication6\ConsoleApplication6\bin>Debug\ConsoleApplication6.exe

4