[英]How to link a .NET 2.0 assembly in a .NET 4.0 solution
I have a project built with .NET 4.0. 我有一个使用.NET 4.0构建的项目。 I have a lot of code that would be painful to convert back to 2.0.
我有很多代码很难转换回2.0。
I try to import a Dll built with .NET 2.0. 我尝试导入使用.NET 2.0构建的Dll。 Everything works until I try to execute code from that DLL.
一切正常,直到我尝试从该DLL执行代码。 It says that it cannot load the specified module or one of its dependency
它说它无法加载指定的模块或其依赖项之一
I used dumpbin.exe to check what dependencies it can have 我使用dumpbin.exe检查它可以具有哪些依赖项
File Type: DLL
Section contains the following imports:
mscoree.dll
402000 Import Address Table
4057F0 Import Name Table
0 time date stamp
0 Index of first forwarder reference
0 _CorDllMain
So my guess here is that the dll tries to load, but cannot find mscoree.dll from version 2.0 and thus raises an Exception. 因此,我的猜测是dll尝试加载,但无法从2.0版中找到mscoree.dll,从而引发异常。
I tried to load my target module manually with 我试图手动加载我的目标模块
Assembly asm = Assembly.LoadFrom(dllPath);
Visual Studio debugger now list the module as loaded, but still it cannot access it. 现在,Visual Studio调试器列出了已加载的模块,但仍无法访问它。 Windows search reports dozens of "mscoree.dll" scattered everywhere in the c:\\windows directory so I'm a little sceptical about loading it manually.
Windows搜索报告数十个“ mscoree.dll”分散在c:\\ windows目录中,因此我对手动加载它有些怀疑。
You are not close to diagnosing the problem. 您还无法诊断问题。 Dumpbin.exe doesn't show you anything that it wouldn't show for any managed assembly.
Dumpbin.exe不会向您显示任何托管程序集都不会显示的内容。 Nor is this a problem that's specific to mixing CLR dependencies.
这也不是混合CLR依赖关系所特有的问题。
Use fuslogvw.exe to find out what dependency is missing. 使用fuslogvw.exe找出缺少的依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.