Determine the processorArchitecture of the running process from managed code

I discussed Figure out the bitness of a process and the ProcessorArchicture of the system back in July 2005.

If you just want to determine the processorArchitecture of the running process from managed code, there is an easier way in .Net framework 2.0.

C:\temp>more test.cs

using System;

using System.Reflection;

public class test

{

    public static void Main()

    {

        Console.WriteLine(typeof(System.Object).Assembly.GetName().ProcessorArchitecture);

    }

}

C:\temp>test

Amd64

This takes advantage of the fact that mscorlib.dll is a platform specific assembly in .Net framework v2.0.