File tree 2 files changed +15
-1
lines changed 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ static NativeMethods()
66
66
{
67
67
if ( Platform . OperatingSystem == OperatingSystemType . Windows )
68
68
{
69
- string path = Path . Combine ( GlobalSettings . NativeLibraryPath , Platform . ProcessorArchitecture ) ;
69
+ string nativeLibraryPath = GlobalSettings . GetAndLockNativeLibraryPath ( ) ;
70
+
71
+ string path = Path . Combine ( nativeLibraryPath , Platform . ProcessorArchitecture ) ;
70
72
71
73
const string pathEnvVariable = "PATH" ;
72
74
Environment . SetEnvironmentVariable ( pathEnvVariable ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public static class GlobalSettings
15
15
private static LogConfiguration logConfiguration = LogConfiguration . None ;
16
16
17
17
private static string nativeLibraryPath ;
18
+ private static bool nativeLibraryPathLocked ;
18
19
19
20
static GlobalSettings ( )
20
21
{
@@ -154,8 +155,19 @@ public static string NativeLibraryPath
154
155
throw new LibGit2SharpException ( "Setting the native hint path is only supported on Windows platforms" ) ;
155
156
}
156
157
158
+ if ( nativeLibraryPathLocked )
159
+ {
160
+ throw new LibGit2SharpException ( "You cannot set the native library path after it has been loaded" ) ;
161
+ }
162
+
157
163
nativeLibraryPath = value ;
158
164
}
159
165
}
166
+
167
+ internal static string GetAndLockNativeLibraryPath ( )
168
+ {
169
+ nativeLibraryPathLocked = true ;
170
+ return nativeLibraryPath ;
171
+ }
160
172
}
161
173
}
You can’t perform that action at this time.
0 commit comments