mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Merge pull request #792 from PowerShell/andschwa/assembly-load
Try Assembly.Load correctly
This commit is contained in:
+12
-7
@@ -186,10 +186,12 @@ namespace System.Management.Automation
|
||||
|
||||
// Try loading it from the TPA list. All PowerShell dependencies are in the
|
||||
// TPA list when published with dotnet-cli.
|
||||
asmLoaded = Assembly.Load(assemblyName);
|
||||
|
||||
try
|
||||
{
|
||||
asmLoaded = Assembly.Load(assemblyName);
|
||||
}
|
||||
// If it wasn't there, try loading from path
|
||||
if (asmLoaded == null)
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
asmLoaded = asmFilePath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
|
||||
? LoadFromNativeImagePath(asmFilePath, null)
|
||||
@@ -250,9 +252,12 @@ namespace System.Management.Automation
|
||||
|
||||
// Try loading it from the TPA list. All PowerShell dependencies are in the
|
||||
// TPA list when published with dotnet-cli.
|
||||
asmLoaded = Assembly.Load(assemblyName);
|
||||
|
||||
if (asmLoaded == null)
|
||||
try
|
||||
{
|
||||
asmLoaded = Assembly.Load(assemblyName);
|
||||
}
|
||||
// If it wasn't there, try loading from path
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// Load the assembly through 'LoadFromNativeImagePath' or 'LoadFromAssemblyPath'
|
||||
asmLoaded = assemblyPath.EndsWith(".ni.dll", StringComparison.OrdinalIgnoreCase)
|
||||
@@ -520,4 +525,4 @@ namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user