Why does the following code crash the executable (I launch from the VS debugger):
static int Main(string[] args)
{
byte[] hash = new byte[20];
GCHandle gch = GCHandle.Alloc(hash, GCHandleType.Pinned);
IntPtr MyPtr = gch.AddrOfPinnedObject();
GCHandle temp = GCHandle.FromIntPtr(MyPtr); //This line crashes the executable (the exception cannot be caught!!!!).
temp.Free();
return 0;
}
The system event log says:
.NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (000007FEF95CAA6E) (80131506)
I am running on Vista x64 SP1 with VS2008 SP1 with .net 3.5 SP1. I have found a thread of discussion where somebody says its a .net bug for which MS provided a February 2009 hotfix:
http://stackoverflow.com/questions/334706/fatal-execution-engine-error-79ffee24-80131506
But when I look up the the listed hotfix ( https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&wa=wsignin1.0) it doesn't say it has any relationship to the problem I'm facing (nor does it say which files I need or how to install them).
Have I found a new .net bug?
-Brent Arias