File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,26 @@ static GlobalSettings()
2323 {
2424 if ( Platform . OperatingSystem == OperatingSystemType . Windows )
2525 {
26- string managedPath = new Uri ( Assembly . GetExecutingAssembly ( ) . EscapedCodeBase ) . LocalPath ;
26+ /* Assembly.CodeBase is not actually a correctly formatted
27+ * URI. It's merely prefixed with `file:///` and has its
28+ * backslashes flipped. This is superior to EscapedCodeBase,
29+ * which does not correctly escape things, and ambiguates a
30+ * space (%20) with a literal `%20` in the path. Sigh.
31+ */
32+ var managedPath = Assembly . GetExecutingAssembly ( ) . CodeBase ;
33+ if ( managedPath == null )
34+ {
35+ managedPath = Assembly . GetExecutingAssembly ( ) . Location ;
36+ }
37+ else if ( managedPath . StartsWith ( "file:///" ) )
38+ {
39+ managedPath = managedPath . Substring ( 8 ) . Replace ( '/' , '\\ ' ) ;
40+ }
41+ else if ( managedPath . StartsWith ( "file://" ) )
42+ {
43+ managedPath = @"\\" + managedPath . Substring ( 7 ) . Replace ( '/' , '\\ ' ) ;
44+ }
45+
2746 nativeLibraryPath = Path . Combine ( Path . Combine ( Path . GetDirectoryName ( managedPath ) , "lib" ) , "win32" ) ;
2847 }
2948
You can’t perform that action at this time.
0 commit comments