You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change PS to load the assembly with 'Assembly.LoadFrom' before 'Assembly.Load' when the file path is given (PowerShell#4196)
It's to solve a side-by-side problem we have with powershell core. If a .NET Core version assembly has the same name as it's .NET ancestor in GAC, then even if you specify the file path to `Import-Module`, powershell core will still load the one in GAC because it tries 'Assembly.Load' first.
Now we change it to use `Assembly.LoadFrom` first when a file path is given, so it works for modules that have side-by-side assemblies.
// this is a legitimate error on CoreCLR for a newly emited with Add-Type assemblies
1354
-
// they cannot be loaded by name, but we are only interested in importing them by path
1355
-
}
1356
-
catch(BadImageFormatExceptionbadImage)
1357
-
{
1358
-
error=badImage;
1359
-
returnnull;
1360
-
}
1361
-
catch(SecurityExceptionsecurityException)
1362
-
{
1363
-
error=securityException;
1364
-
returnnull;
1365
-
}
1366
-
}
1367
-
1368
-
if(loadedAssembly!=null)
1369
-
returnloadedAssembly;
1370
-
1371
-
if(!String.IsNullOrEmpty(filename))
1372
-
{
1373
-
error=null;
1374
-
1375
-
try
1376
-
{
1377
-
loadedAssembly=Assembly.LoadFrom(filename);
1378
-
returnloadedAssembly;
1379
-
}
1380
-
catch(FileNotFoundExceptionfileNotFound)
1381
-
{
1382
-
error=fileNotFound;
1383
-
}
1384
-
catch(FileLoadExceptionfileLoadException)
1385
-
{
1386
-
error=fileLoadException;
1387
-
returnnull;
1388
-
}
1389
-
catch(BadImageFormatExceptionbadImage)
1390
-
{
1391
-
error=badImage;
1392
-
returnnull;
1393
-
}
1394
-
catch(SecurityExceptionsecurityException)
1395
-
{
1396
-
error=securityException;
1397
-
returnnull;
1398
-
}
1399
-
}
1400
-
1401
-
#if !CORECLR// Assembly.LoadWithPartialName is not in CoreCLR. In CoreCLR, 'LoadWithPartialName' can be replaced by Assembly.Load with the help of AssemblyLoadContext.
1402
-
// Finally try with partial name...
1403
-
if(!String.IsNullOrEmpty(fixedName))
1404
-
{
1405
-
try
1406
-
{
1407
-
// This is a deprecated API, use of this API needs to be
0 commit comments