Software development stuff.

2009-04-17

Stuck with static constructor exception

It took me quite some time to understand why I was getting allways the same exception on a static constructor. So this blog confirmed what I suspected. The exception is cached and thrown again:
http://weblogs.asp.net/avnerk/archive/2008/12/16/static-constructor-throws-the-same-exception-again-and-again.aspx
I found this with .NET2.0 I believe .NET 3.5 works differently since they added this to the documentation:
"If a static constructor throws an exception, the runtime will not invoke it a second time, and the type will remain uninitialized for the lifetime of the application domain in which your program is running"