Skip to content

Commit 33bad3a

Browse files
David-Engelcheenamalhotra
authored andcommittedSep 27, 2019
Get last error when LoadLibrary fails (#225)
1 parent c00144f commit 33bad3a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ static SNINativeMethodWrapper()
6161
IntPtr pDll = LoadLibrary(localFolder + subfolder + SNI);
6262
if (pDll == IntPtr.Zero)
6363
{
64-
throw new System.ComponentModel.Win32Exception("Failed to load " + localFolder + subfolder + SNI);
64+
throw new System.ComponentModel.Win32Exception("Failed to load " + localFolder + subfolder + SNI,
65+
new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()));
6566
}
6667
}
6768

@@ -389,7 +390,7 @@ internal struct SNI_Error
389390
#endregion
390391

391392
#region DLL Imports
392-
[DllImport("kernel32.dll")]
393+
[DllImport("kernel32.dll", SetLastError=true)]
393394
public static extern IntPtr LoadLibrary(string dllToLoad);
394395

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

0 commit comments

Comments
 (0)
Please sign in to comment.