Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assembly load priorities when using AssemblyLoadContext #173

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

mhutch
Copy link
Member

@mhutch mhutch commented Jan 10, 2024

Change assembly load behavior when using AssemblyLoadContext to match the behavior when using AppDomain.

Assemblies are now loaded from explicitly referenced assembly paths only after failing to resolve them from loaded assemblies in the host context and after the runtime fails to resolve them from the default context.

Also, when resolving assemblies, give the host ResolveAssemblyReference priority over the list of explicitly referenced assembly paths, as a stopgap to allow it to resolve runtime assemblies when the list contains reference assemblies.

This may be a fix for the underlying issue of dotnet/efcore#32385 but I'm not sure I'm confident to backport it to 2.3.x.

The behavior should now be equivalent to that of the AppDomain codepath:
assemblies are loaded from referenced assembly paths only after
failing to resolve them from loaded assemblies in the host context
and after the runtime fails to resolve them from the default context.
The list of assembly files referenced by the template may contain
reference assemblies, which will fail to load. Letting the host attempt
to resolve the assembly first gives it an opportunity to resolve runtime
assemblies.

Ideally we would have a robust mechanism for resolving runtime
assemblies bue this will have to serve as a stopgap.
@mhutch mhutch merged commit 2257e9e into main Jan 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant