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
A more controversial and/or complete solution could be to extend #27787. Something like
publicinterfaceIDependencyResolver{publicstringResolveAssemblyToPath(AssemblyNameassemblyName);publicstringResolveUnmanagedDllToPath(stringunmanagedDllName);}publicclassAssemblyDependencyResolver:IDependencyResolver{}publicclassAssemblyLoadContext{publicAssemblyLoadContext(IDependencyResolverearlyDependencyResolver);protectedvirtualSystem.Reflection.AssemblyLoad(System.Reflection.AssemblyNameassemblyName){if(earlyResolver){Stringpath=earlyResolver.ResolveAssemblyToPath(assemblyName);if(!path.Empty()){returnLoadFromAssemblyPath(path);}}returnnull;}protectedvirtualIntPtrLoadUnmanagedDll(stringunmanagedDllName){// Similar implementation}}
I think we should do the simple Load returning null.
The second proposal with dependency resolver ventures into the area we've already been, which is trying to come up with a simple solution for "plugin" loads. With the proposed API it would be very simple (2 lines?) to create an ALC to load plugins into, which would dictate a policy decision - which is the problematic part. The above implementation is the "full isolation" policy, which might work for very clear plugin models, but it doesn't work out of the box as it requires for the shared types/assemblies to not be included in the plugin.
I would rather we first make the class non-abstract in the simple manner without additional logic. And try to tackle the "easy to use" APIs later on.
If we decide that we also want the dependency resolver based implementation it can be added later on with relative ease.
I agree with @vitek-karas. The simple implementation of Load() is sufficient for cases where:
We only use ALCs for isolation, with current default Load() semantics
We only alter assembly/unmanaged-library load semantics using events
without creating unnecessary inheritance as in here.
It is reasonable to ALC to be inherited when there is change in assembly-load behavior.
In the way, the second Load() implementation only moves the inheritence hierarchy from ALCs to IDependencyResolver implementations.
Activity
sdmaclea commentedon Jan 10, 2019
A more controversial and/or complete solution could be to extend #27787. Something like
sdmaclea commentedon Jan 10, 2019
/cc @vitek-karas @jkotas @swaroop-sridhar @jeffschwMSFT @sbomer
jkotas commentedon Jan 11, 2019
Both parts look reasonable to me.
vitek-karas commentedon Jan 22, 2019
I think we should do the simple
Loadreturning null.The second proposal with dependency resolver ventures into the area we've already been, which is trying to come up with a simple solution for "plugin" loads. With the proposed API it would be very simple (2 lines?) to create an ALC to load plugins into, which would dictate a policy decision - which is the problematic part. The above implementation is the "full isolation" policy, which might work for very clear plugin models, but it doesn't work out of the box as it requires for the shared types/assemblies to not be included in the plugin.
I would rather we first make the class non-abstract in the simple manner without additional logic. And try to tackle the "easy to use" APIs later on.
If we decide that we also want the dependency resolver based implementation it can be added later on with relative ease.
swaroop-sridhar commentedon Jan 22, 2019
I agree with @vitek-karas. The simple implementation of
Load()is sufficient for cases where:without creating unnecessary inheritance as in here.
It is reasonable to ALC to be inherited when there is change in assembly-load behavior.
In the way, the second
Load()implementation only moves the inheritence hierarchy from ALCs toIDependencyResolverimplementations.sdmaclea commentedon Jan 23, 2019
Moved to dotnet/corefx#34791