-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Microsoft.Data.SqlClient is not compatible with AssemblyLoadContext unloading #31377
Comments
This is the GCRoot dump of the LoaderAllocator instance:
|
@janvorli this looks similar to other problems you helped resolve around this scenario. |
So, there are several things that holds on objects from the unloadable context.
|
One thought I have is why the Microsoft.Data.SqlClient and System.Dynamic.Runtime assemblies are loaded into the unloadable context. @AlbertoCe how does your custom AssemblyLoadContext resolve assembly references? Does it use the AssemblyDependencyResolver? |
Hello @janvorli , I used the sample [https://github.com/dotnet/samples/tree/master/core/tutorials/Unloading].
|
Hello @janvorli , |
@AlbertoCe I am sorry for the delayed response. So, it is clear why the Microsoft.Data.SqlClient was loaded into the unloadable context - I have not realized it is not a shared framework assembly before. And the System.Dynamic.Runtime is actually not loaded into the context, I've said it by mistake. Regarding the Microsoft.Data.SqlClient, the current implementation is not compatible with unloadability, since it creates the timer callback and the strong GC handle. I have looked into it a bit more when I was answering questions on it in another related issue (https://github.com/dotnet/coreclr/issues/27936). It seems the component can be fixed easily to support unloadability by registering for AssemblyLoadContext.Unload event. Until that happens, it seems there might be a workaround that I've mentioned in the other issue. |
@janvorli Is there anything we want to fix around this for 5.0 or is it ok to move to future? |
Tagging subscribers to this area: @vitek-karas, @agocke |
Leaving in 5.0 so loader folks can triage |
Sounds like this is an issue with Microsoft.Data.SqlClient. Created an issue at dotnet/SqlClient#1687. Closing this one. |
Hello,
when I load a plugin that uses EntityFrameworkCore (using a custom collectible AssemblyLoadContext) and try to unload it, it does not get unloaded: the IsActive property of the context's weakreference remain true even after multiple GC.Collect() and GC.WaitForPendingFinalizers().
It works well if I comment out all the EntityFrameworkCore related code from the plugin.
The text was updated successfully, but these errors were encountered: