LoadLibraryW("C:\abc.dll") fails
-
We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.
-
We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.
You might get that because the DLL you are trying to load is dependent on some other DLLs which it cannot find.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
You might get that because the DLL you are trying to load is dependent on some other DLLs which it cannot find.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
The dll's which this dll is dependent are available in the appropriate locations. Also tried verifying them in dependencyWalker. There are no dependency erros seen in it. But still the LoadLibaryW call is failing.
Maybe it's a "bitness" issue, are you sure you are not trying to load -directly or indirectly- a 32 bit DLL into a 64 bit process somewhere or vica versa? Altrough i supose that ahould give a different error, but who knows, maybe when trying to load a DLL which is dependent on another DLL of which it only finds the "wrong" version then it will say "module not found". Speaking of version, could it be some versioning problem? Like the DLL this module is dependent on is some incompatible verison (like, too old)?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
The dll's which this dll is dependent are available in the appropriate locations. Also tried verifying them in dependencyWalker. There are no dependency erros seen in it. But still the LoadLibaryW call is failing.
Eh, another thing i just realized, your question is not C/C++ but rather C# related, maybe you should rather ask on the C# forum.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.
This is the C/C++/MFC forum. May be you should ask in the C# forum. Common errors are typos. So check the path again. Just to be sure: The subject of your question contains the path 'C:\abc.dll' which will fail (must be 'C:\\abc.dll').
-
We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.
Show the actual full code of your failing
LoadLibrary()
call, including (most importantly) the string parameter.Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
We are calling LoadLibary in C#. For this we have included the below code in the C# file. [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] String lpMdoule); We have multiple LoadLibaryW( ) calls. All of them are passing , except one. We verified the GetLastError( ). It returns 126. But the dll is physically existing in the correct path. What could be the reason for dll failure.