-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
NativeLibrary.Load(string, Assembly, DllImportSearchPath?) should honor assembly's ALC #13819
Comments
From chatting with @swaroop-sridhar, the If we were to change that overload of 'NativeLibrary.Load` to actually call those extension points themselves:
@jkotas @vitek-karas Thoughts? |
Do we know about any existing AssemblyLoadContext implementation that would hit the problems you have listed? A few thoughts:
|
I don't know of existing implementations that would hit the compatibility problems. I see assorted implementations of I do think it makes sense that the overload that takes an
But I did want to point out that then the API was added, it was an explicit decision to not do that. @swaroop-sridhar do you have objections to changing this behaviour (if necessary, with the special casing for breaking infinite recursion)? Do you know of any examples that could have compat problems or if we gave out guidance when this was added that would lead to issues? |
I don't have an objection. When the API was added, the main motivating case was the implementation of DllMap. So, the requirements was to be able to call NativeLibrary.Load() from within So, the |
The following overload of NativeLibrary.Load:
NativeLibrary.Load(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
should invoke the
LoadUnmanagedDll
method andResolvingUnmanagedDll
event of the assembly's ALC, in keeping with the API's design intention:Right now, it does not behave as such and ignores the assembly's ALC. Consequently, any assembly calling this method will almost certainly break unless that assembly is loaded into the default ALC. An example is Microsoft.Data.Sqlite, which calls SQLitePCLRaw.nativelibrary. This breaks right now when loaded into a non-default ALC (or when loaded dynamically).
The other overload - NativeLibrary.Load(string libraryPath) - should remain as-is.
See the second/third comment in #13472 for a full discussion.
The text was updated successfully, but these errors were encountered: