''的类型初始值设定项引发了异常 [英] The type initializer for '' threw an exception

查看:1093
本文介绍了''的类型初始值设定项引发了异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个c ++ / cli项目,它是一个Windows应用程序。在调试模式下,我们没有任何问题,但在将其带到释放模式后,此错误启动。我搜索并找到一些论坛答案,但无法帮助我解决这个问题。

请帮帮我....



错误:



未知模块中出现未处理的System.TypeInitializationException类型异常。



附加信息:'Module'的类型初始值设定项引发了异常。

I have a c++/cli project and it's a windows application. In debug mode we didn't have any problems but after taking it to release mode this error start up. I searched and found some forum-answers but couldn't help me solve this problem.
Please help me ....

Error :

An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module.

Additional information: The type initializer for 'Module' threw an exception.

推荐答案

我遇到了同样的错误,发现我引用的类不是问题,但它有声明的另一种类型的静态变量,需要加载另一个程序集。该程序集是为x86的目标平台构建的(参见Properties - > Build选项卡)但是主项目是针对Any CPU编译的。我为任何CPU重建了旧组件......问题解决了。



这里有一些有用的步骤来找出这个问题的根本原因......



点击调试 - >例外并检查所有Thrown复选框。这将导致调试器停止所有第一次机会异常,并将帮助您在您看到的Type Initializer错误下找到错误。如果它与另一个程序集相关,就像我的那样,您可以使用Microsoft的程序集绑定日志查看器工具以帮助确定问题。
I had the same error and found that the class I was referencing was not the problem, but it had a static variable of another type declared that required another assembly to load. That assembly was built for a target platform of x86 (see Properties-->Build tab) however the main project was compiled for Any CPU. I rebuilt the older assembly for Any CPU... problem solved.

Here are some helpful steps for finding the root cause of this problem...

Click Debug--> Exceptions and check ON all the Thrown checkboxes. This will cause the debugger to stop on all first chance exceptions and will help you find the error under the Type Initializer error that you're seeing. If it is related to another assembly, as mine was, you can use Microsoft's Assembly Binding Log Viewer tool to help determine the problem.


运行应用程序的计算机是否具有所有必需的dll?



也许你错过了本地目录中的一些interops
Does the machine where the application is running has all the required dlls??

Maybe you are missing some interops in the local directory


我最近遇到了同样的问题,那是因为我在一个缺少的元素上使用了Date.Parse配置文件:



Date.Parse(System.Configuration.ConfigurationManager.AppSettings.Get(frex))
I recently had the same problem, and it was because I was using Date.Parse on a missing element in the config file:

Date.Parse(System.Configuration.ConfigurationManager.AppSettings.Get("frex"))


这篇关于''的类型初始值设定项引发了异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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