静态构造函数和异常 [英] Static Constructor and Exceptions

查看:229
本文介绍了静态构造函数和异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果静态构造函数抛出和异常,它不处理,会发生什么?

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

将它留到应用领域还活着吗?

Will it remain till the application domain alive?

推荐答案

在静态构造函数的未处理的异常,将被包装在一个 TypeInitializationException 。如果你是在.NET 2或更高版本未处理的异常将终止该进程。

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.

这篇关于静态构造函数和异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆