Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Unable to load DLL (Module could not be found HRESULT: 0x8007007E)

error:Unable to load DLL 'x.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

OS: Windows 7

I have two stations, Visual Studio 2012, using .net 4.0; the other don't have VS installed On the first station with VS2012 I have a C# solution with a C++ project imported. I'm using:

    [DllImport("x.dll", CallingConvention = CallingConvention.Cdecl)]
    [return: MarshalAs(UnmanagedType.I4)]

On this station is working.

But when I moved on the other station (that don't have VS installed) it appear that error. If I install VS, it's working.

What are some possible reasons for this problem to occur? Any ideas on what I could be missing or how I could debug this problem?

like image 244
Ice Avatar asked Dec 25 '22 15:12

Ice


1 Answers

The most likely reason is that the machine which does not have Visual Studio installed is missing the C++ runtime that is needed by your unmanaged DLL. Install the appropriate C++ runtime from the downloadable redistributable.

Do make sure that your unmanaged DLL is linked against the release runtime and not the debug runtime. The latter cannot be redistributed.

You can debug unmanaged DLL dependency issues using tools like Dependency Walker, Process Monitor etc.

like image 101
David Heffernan Avatar answered Dec 28 '22 10:12

David Heffernan