Skip to content

Commit

Permalink
Get last error when LoadLibrary fails (dotnet#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Engel authored and cheenamalhotra committed Sep 27, 2019
1 parent d8ccb74 commit d3f7577
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ static SNINativeMethodWrapper()
IntPtr pDll = LoadLibrary(localFolder + subfolder + SNI);
if (pDll == IntPtr.Zero)
{
throw new System.ComponentModel.Win32Exception("Failed to load " + localFolder + subfolder + SNI);
throw new System.ComponentModel.Win32Exception("Failed to load " + localFolder + subfolder + SNI,
new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()));
}
}

Expand Down Expand Up @@ -389,7 +390,7 @@ internal struct SNI_Error
#endregion

#region DLL Imports
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", SetLastError=true)]
public static extern IntPtr LoadLibrary(string dllToLoad);

[DllImport("secur32.dll", ExactSpelling = true, SetLastError = true)]
Expand Down

0 comments on commit d3f7577

Please sign in to comment.