@@ -1322,71 +1322,71 @@ internal void RemoveAssembly(string name)
1322
1322
[ SuppressMessage ( "Microsoft.Reliability" , "CA2001:AvoidCallingProblematicMethods" , MessageId = "System.Reflection.Assembly.LoadFrom" ) ]
1323
1323
internal static Assembly LoadAssembly ( string name , string filename , out Exception error )
1324
1324
{
1325
- // First we try to load the assembly based on the filename
1326
-
1327
- Assembly loadedAssembly = null ;
1328
- error = null ;
1329
-
1330
- if ( ! String . IsNullOrEmpty ( filename ) )
1331
- {
1332
- try
1333
- {
1334
- loadedAssembly = Assembly . LoadFrom ( filename ) ;
1335
- }
1336
- catch ( FileNotFoundException fileNotFound )
1337
- {
1338
- error = fileNotFound ;
1339
- }
1340
- catch ( FileLoadException fileLoadException )
1341
- {
1342
- error = fileLoadException ;
1343
- }
1344
- catch ( BadImageFormatException badImage )
1345
- {
1346
- error = badImage ;
1347
- }
1348
- catch ( SecurityException securityException )
1349
- {
1350
- error = securityException ;
1351
- }
1352
- }
1353
- else if ( ! String . IsNullOrEmpty ( name ) )
1354
- {
1355
- string fixedName = null ;
1356
- // Remove the '.dll' if it's there...
1357
- fixedName = name . EndsWith ( ".dll" , StringComparison . OrdinalIgnoreCase )
1358
- ? Path . GetFileNameWithoutExtension ( name )
1359
- : name ;
1360
-
1361
- var assemblyString = Utils . IsPowerShellAssembly ( fixedName )
1362
- ? Utils . GetPowerShellAssemblyStrongName ( fixedName )
1363
- : fixedName ;
1364
-
1365
- try
1366
- {
1367
- loadedAssembly = Assembly . Load ( new AssemblyName ( assemblyString ) ) ;
1368
- }
1369
- catch ( FileNotFoundException fileNotFound )
1370
- {
1371
- error = fileNotFound ;
1372
- }
1373
- catch ( FileLoadException fileLoadException )
1374
- {
1375
- error = fileLoadException ;
1376
- // this is a legitimate error on CoreCLR for a newly emited with Add-Type assemblies
1377
- // they cannot be loaded by name, but we are only interested in importing them by path
1378
- }
1379
- catch ( BadImageFormatException badImage )
1380
- {
1381
- error = badImage ;
1382
- }
1383
- catch ( SecurityException securityException )
1384
- {
1385
- error = securityException ;
1386
- }
1387
- }
1388
-
1389
- // We either return the loaded Assembly, or return null.
1325
+ // First we try to load the assembly based on the filename
1326
+
1327
+ Assembly loadedAssembly = null ;
1328
+ error = null ;
1329
+
1330
+ if ( ! String . IsNullOrEmpty ( filename ) )
1331
+ {
1332
+ try
1333
+ {
1334
+ loadedAssembly = Assembly . LoadFrom ( filename ) ;
1335
+ }
1336
+ catch ( FileNotFoundException fileNotFound )
1337
+ {
1338
+ error = fileNotFound ;
1339
+ }
1340
+ catch ( FileLoadException fileLoadException )
1341
+ {
1342
+ error = fileLoadException ;
1343
+ }
1344
+ catch ( BadImageFormatException badImage )
1345
+ {
1346
+ error = badImage ;
1347
+ }
1348
+ catch ( SecurityException securityException )
1349
+ {
1350
+ error = securityException ;
1351
+ }
1352
+ }
1353
+ else if ( ! String . IsNullOrEmpty ( name ) )
1354
+ {
1355
+ string fixedName = null ;
1356
+ // Remove the '.dll' if it's there...
1357
+ fixedName = name . EndsWith ( ".dll" , StringComparison . OrdinalIgnoreCase )
1358
+ ? Path . GetFileNameWithoutExtension ( name )
1359
+ : name ;
1360
+
1361
+ var assemblyString = Utils . IsPowerShellAssembly ( fixedName )
1362
+ ? Utils . GetPowerShellAssemblyStrongName ( fixedName )
1363
+ : fixedName ;
1364
+
1365
+ try
1366
+ {
1367
+ loadedAssembly = Assembly . Load ( new AssemblyName ( assemblyString ) ) ;
1368
+ }
1369
+ catch ( FileNotFoundException fileNotFound )
1370
+ {
1371
+ error = fileNotFound ;
1372
+ }
1373
+ catch ( FileLoadException fileLoadException )
1374
+ {
1375
+ error = fileLoadException ;
1376
+ // this is a legitimate error on CoreCLR for a newly emited with Add-Type assemblies
1377
+ // they cannot be loaded by name, but we are only interested in importing them by path
1378
+ }
1379
+ catch ( BadImageFormatException badImage )
1380
+ {
1381
+ error = badImage ;
1382
+ }
1383
+ catch ( SecurityException securityException )
1384
+ {
1385
+ error = securityException ;
1386
+ }
1387
+ }
1388
+
1389
+ // We either return the loaded Assembly, or return null.
1390
1390
return loadedAssembly ;
1391
1391
}
1392
1392
0 commit comments