Works for me in compiled code in VS 2010, VS 2008, VS 2005 SP1, Mono 1.2.6. It is controlled by reproducing both problems in the window of the Visual Studio 2005 viewer window (I tried with VS 2005 SP1), the compiled code works as expected. (For both tasks, I mean problem 1: βThe expression could not be evaluated,β problem 2: βEnum was out of rangeβ.) Thus, as some commentators noted, this is a VS 2005 window that you stumbled upon . It is surprisingly difficult to quickly find a link to the corresponding error report ...
Otherwise, I would start with a reflection to see what types you are trying to compare (replace Console.Out with any meaningful stream you have access to):
Console.WriteLine("new IntPtr(0) type is: " + new IntPtr(0).GetType()); Console.WriteLine("IntPtr.Zero type is: " + IntPtr.Zero.GetType());
source share