Open
Description
Description
Hi, my application has a plugin architecture and runs on Linux.
I've encountered an issue under the following scenario:
- Create a new assembly load context: new MyAssemblyLoadContext()
- Load an assembly: LoadFromAssemblyPath("my.dll")
- Install a new package
- Unload() - though it should not matter as contexts are supposed to be independent
- Create a new assembly load context: new MyAssemblyLoadContext()
- Load the same assembly again: LoadFromAssemblyPath("my.dll")
The LoadFromAssemblyPath method returns the old version of the assembly, even though the new version is already present on disk.
My context:
internal sealed class PluginLoadContext : AssemblyLoadContext
{
private readonly AssemblyDependencyResolver _resolver;
public PluginLoadContext(string name, assemblyPath)
: base(isCollectible: true, name: name)
{
_resolver = new AssemblyDependencyResolver(assemblyPath);
}
protected override Assembly? Load(AssemblyName assemblyName)
{
var assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
var assembly = assemblyPath != null ? LoadFromAssemblyPath(assemblyPath) : null;
return assembly;
}
}
Reproduction Steps
- Create a new assembly load context: new MyAssemblyLoadContext()
- Load an assembly: LoadFromAssemblyPath("my.dll")
- Install a new package
- Unload() - though it should not matter as contexts are supposed to be independent
- Create a new assembly load context: new MyAssemblyLoadContext()
- Load the same assembly again: LoadFromAssemblyPath("my.dll")
Expected behavior
A new Assembly from the current dll will be loaded
Actual behavior
Returns Assembly loaded by another context
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Type
Projects
Status
No status