Ich werde eine Kernel32-DLL in ASP-Webanwendung verwenden. Dies ist der Code: // DllGetClassObject Funktion Zeiger Signatur private Delegat int DllGetClassObject (Referenz Guid ClassId, Referenz Guid InterfaceId, [Out, MarshalAs (UnmanagedType.Interface)] aus Objekt ppunk);die Funktion LoadLibrary von kernel32.dll gibt Null in Asp-Webanwendung
//Some win32 methods to load\unload dlls and get a function pointer
private class Win32NativeMethods
{
[DllImport("kernel32.dll", CharSet=CharSet.Ansi)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
[DllImport("kernel32.dll")]
public static extern bool FreeLibrary(IntPtr hModule);
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string lpFileName);
}
public string GetTheDllHandle (dllName)
{
IntPtr dllHandle = Win32NativeMethods.LoadLibrary(dllName); // the dllHandle=IntPtr.Zero
return dllHandle.ToString();
}
Das Problem, dass wenn ich meine Funktion GetTheDllHandle nennen, die dllHandle Null zurück
Hat jemand da draußen gemacht etwas ähnliches? Oder hat jemand irgendwelche Vorschläge?
Könnte sein, dass die DLL nicht gäbe, wo man dachte, es tat, könnte ein Rechtsproblem sein könnte etwas ganz anderes sein. Rufen Sie GetLastError auf, um es herauszufinden. –