模块中发生.NET异常(TypeLoadException) [英] A .NET exception (TypeLoadException) occured in the module

查看:173
本文介绍了模块中发生.NET异常(TypeLoadException)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio项目,其中有很多商业DLL文件,我在我的程序中使用。
我已经使用了许多这些DLL文件到目前为止没有任何问题。



昨天我不得不使用另一个DLL文件。我链接DLL文件作为引用(像往常一样),我可以看到它被添加到项目,因为代码完成工作,我可以成功地构建项目。



但是当我在目标计算机上运行它时,我会得到一个TypeLoadException。

 模块中出现.NET异常(TypeLoadException) 

我试图捕获并打印异常中的确切信息,但我根本没有帮助。 / p>

以下是我收到的完整例外:

 模块中出现异常(TypeLoadException)LightSwitch\\\
Error message:无法从程序集Backbone2,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null加载类型'Backbone2.LightMode_Status_Ctr_1'。\\ nnThrowing方法:DiagModule。 SetSwitch\\\

(由于我构建我的项目,我无法执行任何调试并提供更多信息作为dll,然后在目标PC上使用,和a实际上我可以在我的电脑上运行程序,因为它缺少所有必需的硬件)

解决方案

感谢所有的回复,我设法找到问题。
问题是该项目包含几个不同文件夹中的不同版本的库文件(dll)。在运行时(仍然不知道为什么),dll文件将被选择,并且由于不同版本之间的文件是不同的,有些方法丢失。所以将所有文件夹中的DLL文件更新到相同的版本修复了问题。


I have a Visual studio project with lots of commercial DLL files that I use in my program. I have used many of these DLL files so far without any problem.

Yesterday I had to use a yet another DLL file. I linked the DLL file as a referense (as usual), I can see it is added to the project since code-completion works and I could build the project successfully.

But when I run this on the target PC, I get a TypeLoadException.

A .NET exception (TypeLoadException) occured in the module

I tried to catch and print the exact information in the exception but I did not help at all.

Below is the complete exception that I receive:

A .NET exception (TypeLoadException) occured in the module LightSwitch\nError message: Could not load type 'Backbone2.LightMode_Status_Ctr_1' from assembly 'Backbone2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.\nThrowing method: DiagModule.SetSwitch\n

(I can not perform any debugging and provide more info, since I build my project as dll which is then used on the target PC, and actually I can run the program on my PC since it is missing all the required hardware)

解决方案

Thanks for all the replies, I managed to find the issue. The problem was that the project included a couple of library files (dll) with different versions in different folders. During runtime (still don´t know why) a dll file would be choose and since the file was different between different versions, some methods were missing. So updating the DLL files to the same version in all folders fixed the issue.

这篇关于模块中发生.NET异常(TypeLoadException)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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