0

I've got a C# dll and wanted to import it in stdafx.h (another DLL for JNI): import "C:\Users\Marcus Tik\Documents\Visual Studio 2010\Projects\DotNETSpy\DotNETSpy\bin\Release\DotNETSpy.dll" -> Visual Studio said: "Error loading DLL."

Then I used Dependency Walker which says Error: "Modules with different CPU Types where found."

Isn't it standard for a C# DLL to support different CPU Types? How can I solve my problems ? Thanx in advance!

Marcus Tik
  • 1,709
  • 6
  • 20
  • 30
  • 1
    Depends is quite unsuitable for managed assemblies. You can't get a better answer until you describe what you actually want to accomplish. – Hans Passant Mar 09 '12 at 13:34
  • Are you using #import - i.e. are you trying to import a COM object defined in C#? – Phil Mar 22 '12 at 17:37

4 Answers4

4

If you want to check dependencies on a .Net assembly, better use CheckAsm instead of Dependency Walker (at least if you want to see the managed code dependencies, which you probably want).

You can compile managed .Net libraries to 'AnyCPU', so you usually don't have to worry about 32-/64-bit issues. But maybe your DLL depends on an unmanaged DLL, which may cause trouble if the unmanaged library is e.g. 32-bit and you're trying to run it on a 64-bit machine.

sloth
  • 99,095
  • 21
  • 171
  • 219
1

Change the Build option to x86, you might be trying to import a 32 bit OS dll into 64 bit environment.

Check out this link: Access x86 COM from x64 .NET

Community
  • 1
  • 1
Varun Goel
  • 339
  • 3
  • 15
0

If your OS is 32bit and the dll is compiled exclusively for 64bit I think you get that result.

Mattias Åslund
  • 3,877
  • 2
  • 18
  • 17
0

Trying to make the Debug version work is pretty pointless, you can't get the debug version of the CRT libraries deployed. Beware that Dependency Walker is running out of gas on modern executables, it knows nothing about manifests. It will always show them as missing, even when they are not.

The two solutions for this case would be to either use it as a private assembly or to statically link. But remember, this is only for debugging and you should not distribute these files since it is agains the Microsoft terms.

Har
  • 4,864
  • 2
  • 19
  • 22