Throwing exceptions from instance constructors poses no problem. However, throwing them from *static* constructors is not a good idea, since, the static constructors, as opposed to instance constructors, aren't called explicitly, so there's no nice mechanism to handle them.
HTH,
Stefan
I agree, and also I think this is an ugly bug in the framework. Consider situation, that you are using type static constructor, and it is called in another thread. Now you stop the thread. It may happen, that stopping the thread occurs while the static ctor executes. ThreadAbortException is thrown :( . From now, every reference to this type causes to throw the (ThreadAbort) exception. The type is unusable! The only solution I see is to reference all types that have static ctor (which wiil cause to call type's static ctor) before any thread is started. Or maybe someone knows the way to stop thread safely (without throwing the ThreadAbortException) ?
Best regards. Lukasz
=================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
