LoadLibrary

Jan 5, 2013 at 11:21 PM

Happy new year!

I have a third party native dll.

I can use the native dll inside my c# dll at my c# console application without problem. (I only need to put the 3rd party library in the same folder, will be loaded automatically.)

However when I use my c# dll in ExcelDNA as external library, it seems the 3rd party library is not loaded.

So I decide to load it in ExcelDNA's C++ project such as somewhere in xlAutoOpen().

However, it just hang in there, does not give any error message

However, I can load it in my standalone C++ console application such as:

DWORD err;

 HINSTANCE hDLL =LoadLibrary(L"C:/bin/Debug/ThirdPartyNative.dll");

if(hDLL != NULL)

{

printf("Library has been loaded\n");       

}

else

{               

err = GetLastError(); printf("Couldn't load dll\n");

}

 

Any idea?

Thanks!

Coordinator
Jan 7, 2013 at 2:11 PM

Hi,

Are you calling LoadLibrary explicitly, or using P/Invoke (DllImport) from the C#?

Are you using the full path in the DllImport attribute? The .xll directory is not necessarily the current directory, or in the Windows .dll search path.

-Govert

Jan 8, 2013 at 8:18 PM

I use LoadLibrary implicitly inside xlAutoOpen() or afrer xlAutoOpen() was called by:

LoadLibrary(L"C:/bin/Debug/ThirdPartyNative.dll")

 

It just hang in there. Any idea? 

Thanks!


Jan 8, 2013 at 8:18 PM

I mean: explicitly call LoadLibrary inside xlAutoOpen() or afrer xlAutoOpen() was called.

Coordinator
Jan 8, 2013 at 9:03 PM

Hi,

Does your library interact with Excel at all?

Can you run under the debugger, and look for any suspicious messages, or try to see why the thread is blocked?

Can you try with a really simple .dll that you make yourself?

-Govert