本文介绍了向Program类抛出TypeInitializationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我的Windows Forms应用程序较早运行,但是突然停止了工作。我遇到以下异常:My Windows Forms application was working earlier, however suddenly it stopped working. I am getting following 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!