Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static Constructor and Exceptions

Tags:

c#

constructor

What happen if a static constructor throws and exception and it is not handled?

Will it remain till the application domain alive?

like image 247
Amutha Avatar asked Jan 02 '11 15:01

Amutha


1 Answers

An unhandled exception in a static constructor, will be wrapped in a TypeInitializationException. If you're on .NET 2 or newer an unhandled exception will terminate the process.

like image 144
Brian Rasmussen Avatar answered Sep 28 '22 17:09

Brian Rasmussen