mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove ClrFacade.Load
Instead, rely on intercepting Assembly.Load
This commit is contained in:
committed by
Andrew Schwartzmeyer
parent
6356a5a778
commit
c78732d226
@@ -1148,7 +1148,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// First try by strong name
|
||||
try
|
||||
{
|
||||
loadedAssembly = ClrFacade.Load(new AssemblyName(assemblyName));
|
||||
loadedAssembly = Assembly.Load(new AssemblyName(assemblyName));
|
||||
}
|
||||
// Generates a FileNotFoundException if you can't load the strong type.
|
||||
// So we'll try from the short name.
|
||||
@@ -2050,7 +2050,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// First try by strong name
|
||||
try
|
||||
{
|
||||
loadedAssembly = ClrFacade.Load(assemblyName);
|
||||
loadedAssembly = Assembly.Load(assemblyName);
|
||||
}
|
||||
// Generates a FileNotFoundException if you can't load the strong type.
|
||||
// So we'll try from the short name.
|
||||
@@ -2062,7 +2062,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// Next, try an exact match
|
||||
if (StrongNames.Value.ContainsKey(assemblyName))
|
||||
{
|
||||
return ClrFacade.Load(StrongNames.Value[assemblyName]);
|
||||
return Assembly.Load(StrongNames.Value[assemblyName]);
|
||||
}
|
||||
|
||||
// If the assembly name doesn't contain wildcards, return null. The caller generates an error here.
|
||||
@@ -2105,7 +2105,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
return null;
|
||||
|
||||
// Otherwise, load the assembly.
|
||||
return ClrFacade.Load(matchedStrongName);
|
||||
return Assembly.Load(matchedStrongName);
|
||||
}
|
||||
|
||||
private static ConcurrentDictionary<string, string> InitializeStrongNameDictionary()
|
||||
|
||||
@@ -1559,7 +1559,7 @@ namespace System.Management.Automation
|
||||
|
||||
try
|
||||
{
|
||||
loadedAssembly = ClrFacade.Load(new AssemblyName(assemblyString));
|
||||
loadedAssembly = Assembly.Load(new AssemblyName(assemblyString));
|
||||
}
|
||||
catch (FileNotFoundException fileNotFound)
|
||||
{
|
||||
|
||||
@@ -5674,7 +5674,7 @@ if($paths) {
|
||||
try
|
||||
{
|
||||
// WARNING: DUPLICATE CODE see RunspaceConfigForSingleShell
|
||||
assembly = ClrFacade.Load(new AssemblyName(psSnapInInfo.AssemblyName));
|
||||
assembly = Assembly.Load(new AssemblyName(psSnapInInfo.AssemblyName));
|
||||
}
|
||||
catch (BadImageFormatException e)
|
||||
{
|
||||
|
||||
+1
-1
@@ -662,7 +662,7 @@ namespace System.Management.Automation.Remoting
|
||||
{
|
||||
try
|
||||
{
|
||||
result = ClrFacade.Load(new AssemblyName(assemblyName));
|
||||
result = Assembly.Load(new AssemblyName(assemblyName));
|
||||
}
|
||||
catch (FileLoadException e)
|
||||
{
|
||||
|
||||
@@ -667,7 +667,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
else
|
||||
{
|
||||
providerAssembly = ClrFacade.Load(providerInfo.AssemblyName);
|
||||
providerAssembly = Assembly.Load(providerInfo.AssemblyName);
|
||||
}
|
||||
|
||||
try
|
||||
|
||||
@@ -618,7 +618,7 @@ namespace System.Management.Automation.Runspaces
|
||||
try
|
||||
{
|
||||
// WARNING: DUPLICATE CODE see InitialSessionState
|
||||
assembly = ClrFacade.Load(new AssemblyName(mshsnapinInfo.AssemblyName));
|
||||
assembly = Assembly.Load(new AssemblyName(mshsnapinInfo.AssemblyName));
|
||||
}
|
||||
catch (FileLoadException e)
|
||||
{
|
||||
|
||||
@@ -279,32 +279,6 @@ namespace System.Management.Automation
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Porting note: Load assembly by name through the AssemblyLoadContext.
|
||||
/// This is to ensure that the types get cached.
|
||||
/// </summary>
|
||||
internal static Assembly Load(AssemblyName assembly)
|
||||
{
|
||||
#if CORECLR
|
||||
return PSAssemblyLoadContext.LoadFromAssemblyName(assembly);
|
||||
#else
|
||||
return Assembly.Load(assembly);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Same as the above, but overloaded for a name in a string.
|
||||
/// </summary>
|
||||
internal static Assembly Load(string assembly)
|
||||
{
|
||||
#if CORECLR
|
||||
return PSAssemblyLoadContext.LoadFromAssemblyName(new AssemblyName(assembly));
|
||||
#else
|
||||
return Assembly.Load(assembly);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Facade for EnumBuilder.CreateTypeInfo
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user