Plugin that uses managed Sql client library won't allow unloading the assembly
lucashby opened this issue · 2 comments
Describe the bug
I am using the managed Sql client library (Microsoft.Data.SqlClient version 4.1.0) in a plugin, but doing so doesn't allow the loader to unload the context.
To Reproduce
Steps to reproduce the behavior:
- Please see my GH repo that reproduces the issue here, https://github.com/lucashby/plugins
- The console spits out at the end if the WeakReference is still alive, and it is but shouldn't be
Expected behavior
I would expect with the SqlConnection.ClearAllPools() and the AppContext switch they added for the SqlClient to force usage of the managed client, even on Windows, for the loader to unload the plugin assembly.
EDIT: spelling
This is beyond this project's ability to fix. This is an issue in the .NET runtime itself and how it handles unloading of native assemblies (e.g. you can't unload native dependencies). You will need to request help from .NET for this.
This is beyond this project's ability to fix. This is an issue in the .NET runtime itself and how it handles unloading of native assemblies (e.g. you can't unload native dependencies). You will need to request help from .NET for this.
That seems odd because the AppContext switch is supposed to make it so it explicitly does NOT use the native assemblies.
"This switch will toggle the driver's behavior to use a managed networking implementation in .NET Core 2.1+ and .NET Standard 2.0+ projects on Windows, eliminating all dependencies on native libraries for the Microsoft.Data.SqlClient library."