File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ static NativeMethods()
6666 {
6767 if ( Platform . OperatingSystem == OperatingSystemType . Windows )
6868 {
69- string path = Path . Combine ( GlobalSettings . NativeLibraryPath , Platform . ProcessorArchitecture ) ;
69+ string nativeLibraryPath = GlobalSettings . GetAndLockNativeLibraryPath ( ) ;
70+
71+ string path = Path . Combine ( nativeLibraryPath , Platform . ProcessorArchitecture ) ;
7072
7173 const string pathEnvVariable = "PATH" ;
7274 Environment . SetEnvironmentVariable ( pathEnvVariable ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public static class GlobalSettings
1515 private static LogConfiguration logConfiguration = LogConfiguration . None ;
1616
1717 private static string nativeLibraryPath ;
18+ private static bool nativeLibraryPathLocked ;
1819
1920 static GlobalSettings ( )
2021 {
@@ -154,8 +155,19 @@ public static string NativeLibraryPath
154155 throw new LibGit2SharpException ( "Setting the native hint path is only supported on Windows platforms" ) ;
155156 }
156157
158+ if ( nativeLibraryPathLocked )
159+ {
160+ throw new LibGit2SharpException ( "You cannot set the native library path after it has been loaded" ) ;
161+ }
162+
157163 nativeLibraryPath = value ;
158164 }
159165 }
166+
167+ internal static string GetAndLockNativeLibraryPath ( )
168+ {
169+ nativeLibraryPathLocked = true ;
170+ return nativeLibraryPath ;
171+ }
160172 }
161173}
You can’t perform that action at this time.
0 commit comments