views:

95

answers:

2

I have a project built with .NET 4.0. I have a lot of code that would be painful to convert back to 2.0.

I try to import a Dll built with .NET 2.0. Everything works until I try to execute code from that 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

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.

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. Windows search reports dozens of "mscoree.dll" scattered everywhere in the c:\windows directory so I'm a little sceptical about loading it manually.

+3  A: 

You are not close to diagnosing the problem. Dumpbin.exe doesn't show you anything that it wouldn't show for any managed assembly. Nor is this a problem that's specific to mixing CLR dependencies.

Use fuslogvw.exe to find out what dependency is missing.

Hans Passant
+1  A: 
  1. Start by finding all of its dependencies. The fact that you haven't listed them here is troubling.
  2. Have you application directly reference all of said dependencies.
Jonathan Allen