Skip to content

Commit

Permalink
Database: Fix SNI.dll loading [STUD-70051]
Browse files Browse the repository at this point in the history
Use Assembly.Location instead of Assembly.CodeBase (since CodeBase is deprecated)
For UNC path we were parsing incorrectly the file:/// prefix
  • Loading branch information
viogroza committed Sep 2, 2024
1 parent 6337d2f commit bdbceca
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ public static void SNILoadWorkaround(bool isWindows = true)
if(!isWindows)
return;

IntPtr Handle = LoadLibrary(Path.GetFullPath((typeof(DbWorkarounds).Assembly.CodeBase.Replace("file:///", "")) + RelativePath));

var asmLocation = typeof(DbWorkarounds).Assembly.Location;
var path = Path.GetFullPath(asmLocation + RelativePath);
IntPtr Handle = LoadLibrary(path);
if (Handle == IntPtr.Zero)
{
int errorCode = Marshal.GetLastWin32Error();
throw new Exception(string.Format("Failed to load library (ErrorCode: {0})", errorCode));
string errorMessage = string.Format("Failed to load library {0} (ErrorCode: {1})",
path, errorCode);
throw new Exception(errorMessage);
}
}
}
Expand Down

0 comments on commit bdbceca

Please sign in to comment.