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

1 comment:

  1. This is an important aspect for people dealing with math in .NET code. Although we compile our math library in platform agnostic mode, we have had quite a few issues in the past getting same test results in 32-bit and 64-bit platforms. In particular, errors add up differently in these two platforms.

    ReplyDelete