tags:

views:

504

answers:

3

Hi Everyone,

I found Stack Overflow is one among the best group for all our clarifications. I have the native dll written in C. I compiled the proj using VC++ (VS 2008), Using my C# application I called the dll functions through Dllimport. The problem is it fails to load the dll. It says unable to load the dll.

I have compiled to the platform from x86 to x64 both my dll and my application. It would be really great if you guys help me for resolving this issue.

Is there any possibility to check whether why the dll is not loaded.

Thanks in advance.

+1  A: 

Try using sysinternal's Process Monitor to see where you application is looking to load the dll from.

The Win32 documenation for LoadLibrary links to details on how it searches for the dll.

Richard
+1  A: 

I had a problem with this once along these lines. I had a C++ DLL that acted as an interface to a piece of hardware, that I needed to call from C#. However, it would fail the DllImport call if the piece of hardware was not plugged in. This is because the DLL initialisation function was returning a failure, so C# just said it couldn't load the DLL, it may not be to do with where the DLL is.

Check that you are not causing some sort of error when you are setting up the DLL in your C code.

Kazar
A: 

The Dependency Walker is a nice tool to analyze the stuff a dll uses to load. For native executables it is aslo able to load the exe and use "Profile" menu entry to even show the dll that were loaded using delay load which will not show up if just the dll is loaded.

Totonga