Possible Duplicate:
What is the use of static constructors?
From MSDN: – “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.”
Would you still use Static Constructors for programming construct? Here I’m trying to list down scenarios where and where not one should avail the benefit provided by CLR through the use of Static Constructors.
Sometimes, yes – but only for small things which are staggeringly unlikely to throw exceptions… or where a failure represents a calamitous scenario where the app is fundamentally unusable.
Note that everything you quoted there is true of any static initialization – not just static constructors. So if you have:
then that still comes under the same restrictions. Fundamentally, if type initialization fails, your type is unusable. That shouldn’t come as any surprise really, and it doesn’t mean that it’s useless.