向Program类抛出TypeInitializationException [英] TypeInitializationException thrown for Program class
问题描述
我的Windows Forms应用程序较早运行,但是突然停止了工作。我遇到以下异常:
My Windows Forms application was working earlier, however suddenly it stopped working. I am getting following exception:
异常细节如下:
未处理System.TypeInitializationException < br>
消息:mscorlib.dll中发生了类型为'System.TypeInitializationException'的未处理异常。
其他信息:'NotificationTester.Program'的类型初始化器引发了异常。
System.TypeInitializationException was unhandled
Message: An unhandled exception of type 'System.TypeInitializationException' occurred in mscorlib.dll
Additional information: The type initializer for 'NotificationTester.Program' threw an exception.
当我单击确定时,VS窗口将显示以下内容:
When I click OK, the VS windows then shows following:
该解决方案之前运行良好。我不明白发生了什么问题。
The solution was working fine earlier. I don't get whats going wrong.
推荐答案
所以:对于字段初始化器之一或静态构造器, 程序
-失败。找出为什么。注意: InnerException
具有引发的实际异常,但是从根本上来说:只需调试字段初始化器和静态构造函数即可。因此,在 Program
类中查找以下任意一个:
So: either one of the field-initializers, or the static constructor, for Program
- is failing. Find out why. Note: the InnerException
has the actual exception that was raised, but basicaly: just debug the field initializers and static constructor. So look inside the Program
class for either:
static SomeType someField = /* some non-trivial expression or method call */
or:
static Program() {
// stuff
}
这篇关于向Program类抛出TypeInitializationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!