模块中发生 .NET 异常 (TypeLoadException)
我有一个 Visual Studio 项目,其中包含我在程序中使用的大量商业 DLL 文件。 到目前为止,我已经使用了许多这样的 DLL 文件,没有任何问题。
昨天我不得不使用另一个 DLL 文件。我链接了 DLL 文件作为参考(像往常一样),我可以看到它已添加到项目中,因为代码完成工作正常,并且我可以成功构建项目。
但是当我在目标 PC 上运行它时,我收到 TypeLoadException。
A .NET exception (TypeLoadException) occured in the module
我试图捕获并打印异常中的确切信息,但我根本没有帮助。
下面是我收到的完整异常:(
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
我无法执行任何调试并提供更多信息,因为我将项目构建为 dll,然后在目标 PC 上使用,实际上我可以在我的 PC 上运行该程序,因为它是缺少所有必需的硬件)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
检查 dll 是否是为与您的电脑相同的体系结构构建的。我的意思是,如果你的电脑是 64 位,请确保 dll 是相应构建的,反之亦然
Check whether the dll is built for the same architecture as your pc. I mean, if your pc is 64 bit, make sure that the dll is built corresponding to that and vice versa
感谢大家的回复,我已经找到问题所在了。
问题是该项目包含几个不同文件夹中不同版本的库文件 (dll)。在运行时(仍然不知道为什么)会选择一个dll文件,并且由于不同版本之间的文件不同,因此缺少一些方法。因此,将所有文件夹中的 DLL 文件更新为相同版本解决了该问题。
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.
检查 DLL 是否位于目标 PC 上的正确位置(或在 GAC 中)。
Check that the DLL is in the right location (or in GAC) on the target PC.
启动 FusLogVw.exe——它是 .Net SDK 的一部分,可以从 VS 2010 命令提示符启动。配置日志记录以记录所有失败。重现问题,刷新 FusLogVw.exe 窗口中的视图。您应该能够找到与您的问题相对应的记录,它会准确地告诉您它正在做什么,并且您应该能够弄清楚如何纠正问题。
Launch FusLogVw.exe -- it is part of .Net SDK and could be launched from VS 2010 command prompt. Configure logging to record all failures. Reproduce problem, refresh view in FusLogVw.exe window. You should be able to find record that corresponds to your problem, it will tell you exactly what it is doing and you should be able to figure out how to correct the problem.
检查您是否引用了 DLL 的一个版本,并且在运行时加载了另一个版本(从 GAC)。
Check if you are reference one version of the DLL and another one is loaded (from GAC) during runtime.