The implementation of StandardAssemblyLoader.LoadAssembly is supposed to consider the codeBasePath parameter when locating the assembly. It attempts to do this by setting the AssemblyName.CodeBase property before calling Assembly.Load(AssemblyName).
var assemblyName = new AssemblyName(assemblyFullName);
if (!string.IsNullOrEmpty(codeBasePath))
{
assemblyName.CodeBase = codeBasePath;
}
// ends up calling Assembly.Load(AssemblyName)
return this.LoadAssembly(assemblyName);
.NET Core does not respect AssemblyName.CodeBase though hence this has no impact there.
The rough equivalent of this pattern for .NET Core is the following:
var alc =
AssemblyLoadContext.CurrentContextualReflectionContext
?? AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly());
try
{
return alc.LoadFromAssemblyName(new AssemblyName(assemblyFullName);
}
catch
{
return alc.LoadFromAssemblyPath(codeBase);
}
Hard to 100% tell what the use case is here though as I can't find callers of IAssemblyLoader.LoadAssembly(string, string) in the repo.
Note: this code will appropriately get SYSLIB0044 warnings when targeting net8.0.
The implementation of
StandardAssemblyLoader.LoadAssemblyis supposed to consider thecodeBasePathparameter when locating the assembly. It attempts to do this by setting theAssemblyName.CodeBaseproperty before callingAssembly.Load(AssemblyName)..NET Core does not respect
AssemblyName.CodeBasethough hence this has no impact there.The rough equivalent of this pattern for .NET Core is the following:
Hard to 100% tell what the use case is here though as I can't find callers of
IAssemblyLoader.LoadAssembly(string, string)in the repo.Note: this code will appropriately get SYSLIB0044 warnings when targeting
net8.0.