Explorar o código

Bug 1932: Failure when using from single-file bundle

https://winscp.net/tracker/1932

Source commit: 4e32bb19ca43c6e0b1af8322e820fa3024ee0ff9
Martin Prikryl %!s(int64=4) %!d(string=hai) anos
pai
achega
12de0105c4
Modificáronse 1 ficheiros con 12 adicións e 1 borrados
  1. 12 1
      dotnet/internal/Logger.cs

+ 12 - 1
dotnet/internal/Logger.cs

@@ -42,7 +42,18 @@ namespace WinSCP
 
             // It's also good to know that the CodeBase is not guaranteed to be set for assemblies in the GAC.
             // Location will always be set for assemblies loaded from disk, however.
-            string codeBase = assembly.CodeBase;
+            string codeBase;
+            try
+            {
+                codeBase = assembly.CodeBase;
+            }
+            catch (NotSupportedException e)
+            {
+                // CodeBase is not supported on assemblies loaded from a single-file bundle
+                WriteLine($"CodeBase not supported: {e.Message}");
+                codeBase = string.Empty;
+            }
+
             string location = assembly.Location;
 
             // cannot use Uri.UnescapeDataString, because it treats some characters valid in