DLLimport cannot load DLL

I am using an unmanaged dll in cpp, which I am calling from my C # web project. It works fine on my localhost, but just doesn't work on my shared hosting, winhost. This happens when I try to use one of the functions in the dll.

The error message I get is:

"Unable to load DLL 'dllTest.dll': the application failed to start because its side-by-side configuration is incorrect. See the application event log or use the sxstrace.exe command-line tool for more details. (Exception from HRESULT: 0x800736b1)" "error ": [{" Name ":" DllNotFoundException "," message ":" Unable to load the DLL 'dllTest.dll': the application did not start because it was improperly configured side by side. See the application event log or use the sxstrace command-line tool .exe for more details. (Exception from HRESULT: 0x800736B1) "}]}

I suspect this is the way to go. The dll in question, dllTest.dll is placed in my bin folder. I am not sure where it is looking for a DLL, but there is a way to specify the path for the dll search. I can not find a way to specify the relative path to the dll.

I don’t think this is a dependency problem, because my dllTest.dll is just a simple test and it contains only a simple add function.

Or could there be other reasons?

Thanks for the help.

+7
source share
1 answer

The problem is that your C ++ DLL requires the CRT libraries to be installed to work. The bold part of the error message gives you a hint:

Unable to load DLL "dllTest.dll": The application could not be started because its side-by-side configuration is incorrect. . See the application event log or use the sxstrace.exe command line command for more details.

This explains why everything is fine on your development machine - they are already installed there, because they are installed with your development tools and mdash, and why it does not work on a production server that does not have common CRT distributions installed.

You need to download the appropriate redistributable package for the version of Visual Studio with which you compiled the DLL. For example, if you are using Visual Studio 2010, you can download version 10 of the distributed CRT here .

Alternatively, you can compile a DLL with statically linked runtime libraries. To do this, change the project properties to reset /MT instead of /MD - (it is found in the user interface under "Configuration Properties" β†’ "C / C ++" β†’ "Code Generation" β†’ "Runtime Library").

+13
source

All Articles