LoadLibraryW(dllpath) 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.
The likeliest problem is that something the DLL you are trying to load relies on can't be found in the path.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
The likeliest problem is that something the DLL you are trying to load relies on can't be found in the path.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Did you read my answer? I said that something the DLL relies on is probably outside the path.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
.DLL's sometimes are not standalone modules. It's entirely possible the .DLL you're trying to load uses another .DLL that you don't have somewhere where it can be found. Use this[^] to find out what that dependancy might be. Just open the .DLL that's failing in it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
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.
The error code means that the file cannot be found. As I requested in the C++ forum, please show the exact code (including the string parameter) of the call that fails. We cannot guess what is happening inside your program. At a (bad) guess, based on what you wrote in the C++ forum, your code looks like:
LoadLibaryW("C:\abc.dll");
which will most likely fail as the backslash needs to be escaped.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
The error code means that the file cannot be found. As I requested in the C++ forum, please show the exact code (including the string parameter) of the call that fails. We cannot guess what is happening inside your program. At a (bad) guess, based on what you wrote in the C++ forum, your code looks like:
LoadLibaryW("C:\abc.dll");
which will most likely fail as the backslash needs to be escaped.
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
Where's the DLL name? You've just provided a path there - there's no DLL details, so how can you expect
LoadLibraryW
to pick up the DLL?*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility