I strongly suspect this is caused by this optimization (related to BeforeFieldInit) in .NET 4.0.
If I remember correctly:
When you declare a static constructor explicitly, beforefieldinit
is emitted, telling the runtime that the static constructor must be run before any static member access.
My guess:
I'd guess that they somehow screwed up this fact on the x64 JITer, so that when a different type's static member is accessed from a class whose own static constructor has already run, it somehow skips running (or executes in the wrong order) the static constructor -- and therefore causes a crash. (You don't get a null pointer exception, probably because it's not null-initialized.)
I have not run your code, so this part may be wrong -- but if I had to make another guess, I'd say it might be something string.Format
(or Console.WriteLine
, which is similar) needs to access internally that's causing the crash, such as perhaps a locale-related class which needs explicit static construction.
Again, I haven't tested it, but it's my best guess at the data.
Feel free to test my hypothesis and let me know how it goes.