用户代码未处理TypeInitializationException [英] TypeInitializationException was unhandled by user code

查看:108
本文介绍了用户代码未处理TypeInitializationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


我正在为我的edi翻译项目使用第三方参考。我从www.edidev.com获得了试用版。我正在开发一个基于Windows的c#应用程序,它可以从x12文件中获取值。在按钮单击事件中,我通过dll文件创建对象。当该特定行被执行时,我得到此异常。

TypeInitializationException未被用户代码处理

并且还说< module>没有初始化。帮帮我

hi
I am using a thirdparty reference for my edi translator project. i got the trial version from www.edidev.com . I am developing a windows based c# application that can get the values from the x12 file. Inside a button click event i create an object by the dll file. when that particular line is getting executed i get this exception.
TypeInitializationException was unhandled by user code
And also says <module> is not initialised.Help me out

推荐答案

你好,



阅读:

http://www.dotnetperls.com/typeinitializationexception [ ^ ]

如果你有一个静态构造函数,你的程序将抛出 TypeInitializationException


此异常显示在application.run(new form1)行
this exception is shown on application.run(new form1) line


有更好的解释 MSDN [ ^ ]

ie

当类初始值设定项时无法初始化类型,创建了TypeInitializationException并传递了一个refe依赖于类型'的类初始值设定项抛出的异常。 TypeInitializationException的InnerException属性保存基础异常。



即在您的情况下,您在按钮单击JIT上定义了第三方dll中定义的类的本地成员变量尝试加载DLL但加载失败并触发此异常。检查dll引用和其他相关文件是否在可执行文件的同一文件夹中。



发布异常堆栈以获得更好的答案。

/编辑OP后的新评论。



找不到msvcr80.dll [ ^ ]

msvcr80-dll-not-found-missing-error.htm [ ^ ]
A better explanation is available in MSDN[^]
i.e
When a class initializer fails to initialize a type, a TypeInitializationException is created and passed a reference to the exception thrown by the type''s class initializer. The InnerException property of TypeInitializationException holds the underlying exception.

ie in your case you you defined a local member variable of the class defined in the thirdparty dll, on button click JIT try to load the dll but failed load and fired this exception. check the dll reference and other related files are in the same folder of your executable.

Post the exception stack for more better answer.
/EDIT After OPs new comment.

msvcr80.dll not found[^]
msvcr80-dll-not-found-missing-error.htm[^]


这篇关于用户代码未处理TypeInitializationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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