From bdbceca51bb4c08b4918d5a146ad6ff7ce99d85e Mon Sep 17 00:00:00 2001 From: viogroza Date: Mon, 2 Sep 2024 12:31:56 +0300 Subject: [PATCH] Database: Fix SNI.dll loading [STUD-70051] Use Assembly.Location instead of Assembly.CodeBase (since CodeBase is deprecated) For UNC path we were parsing incorrectly the file:/// prefix --- .../Workaround/DbWorkarounds.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Activities/Database/ConnectionDialog/UiPath.Data.ConnectionUI.Dialog/Workaround/DbWorkarounds.cs b/Activities/Database/ConnectionDialog/UiPath.Data.ConnectionUI.Dialog/Workaround/DbWorkarounds.cs index 2a494662..0f416f19 100644 --- a/Activities/Database/ConnectionDialog/UiPath.Data.ConnectionUI.Dialog/Workaround/DbWorkarounds.cs +++ b/Activities/Database/ConnectionDialog/UiPath.Data.ConnectionUI.Dialog/Workaround/DbWorkarounds.cs @@ -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); } } }