-
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
API: Native Library Resolve Event #27647
Comments
|
Thanks @jkotas, I've fixed it now. |
The existing events on AssemblyLoadContext use Action/Func. Do we want to follow the same style? |
In I wrote in event in the EventHandler style following these guidelines. |
I'm worried about naming consistency. On managed side we have |
I think it's important to mention that there are 2 reasons to add this:
|
I also think it would be a good idea to describe the proposed ordering of the various hooks. It starts with a call to a |
Following on to @vitek-karas's comment, the official guidance for |
I've updated the naming, and added a section on DllImport order. |
Sure, once the feature is checked in/released, we should update it. |
This change adds the Native library resolving event, to be raised when the runtime cannot resolve a native library load. ```C# namespace System.Runtime.Loader { public abstract class AssemblyLoadContext { public event Func<Assembly, string, IntPtr> ResolvingUnmanagedDll; } } ``` With this change, the DllImport resolution sequence is as follows: (stopping at any step the library is successfully loaded) If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() Run the default load logic, try loading from: AppDomain cache NATIVE_DLL_SEARCH_DIRECTORIES Invoking-assembly directory, System32, etc. based on DllImportSearchPaths Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850 The ResolveEventTests triggered a pre-existing bug in the exception handling code (#21964). Disabling the test on ARM64 Windows until the issue is fixed.
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850 The ResolveEventTests triggered a pre-existing bug in the exception handling code (#21964). Disabling the test on ARM64 Windows until the issue is fixed.
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850 The ResolveEventTests triggered a pre-existing bug in the exception handling code (#21964). Disabling the test on ARM64 Windows until the issue is fixed.
This change adds the Native library resolving event, to be raised as the last attempt to resolve a native DLL in an AssemblyLoadContext. With this change, the DllImport resolution sequence is as follows (stopping at any step with successful resolution): * If the invoking-assembly is not in the default load context, call AssemblyLoadContext.LoadUnmanagedDll() * Run the default load logic, try loading from: * AppDomain cache * NATIVE_DLL_SEARCH_DIRECTORIES * Invoking-assembly directory, System32, etc. based on DllImportSearchPaths * Raise the ResolvingUnmanagedDll event API Review: https://github.com/dotnet/corefx/issues/32850 The ResolveEventTests triggered a pre-existing bug in the exception handling code (#21964). Disabling the test on ARM64 Windows until the issue is fixed.
Expose System.Runtime.Loader.AssemblyLoadContext.ResolvingUnmanagedDll API Review: https://github.com/dotnet/corefx/issues/32850 Implementation: https://github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs#L549 Tests: https://github.com/dotnet/coreclr/blob/master/tests/src/Interop/NativeLibraryResolveEvent/ResolveEventTests.cs
Expose System.Runtime.Loader.AssemblyLoadContext.ResolvingUnmanagedDll API Review: https://github.com/dotnet/corefx/issues/32850 Implementation: https://github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs#L549 Tests: https://github.com/dotnet/coreclr/blob/master/tests/src/Interop/NativeLibraryResolveEvent/ResolveEventTests.cs
Closed with dotnet/corefx#34668 |
This proposal adds a Native library resolving event, to be raised when the runtime cannot resolve a native library load.
Proposed API
Rationale
In the case of Loading assemblies, the runtime provides the application to customize the load at various phases:
AssemblyLoadContext.Load()
method overridesAssemblyLoadContext.Resolving
event handlers.This proposal creates a matching facility for unmanaged libraries
AssemblyLoadContext.LoadUnmanagedDll()
and separately proposedDllImportResolver
callbacksAssemblyLoadContext.ResolvingUnmanagedDll
event.In particular, the
NativeLibraryResolve
event is expected to provide flexibility for running custom native library resolution logic from plugins. Hence the motivation to have the event per AssemblyLoadContext, rather than globally.DllImport sequence
DllImport load library works in the following order, stop at any step the library is successfully loaded.
DllImportResolver
callback registered, invoke it.AssemblyLoadContext.LoadUnmanagedDll()
DllImportSearchPaths
Discussion
Alternate notation
In this proposal
ResolvingUnmanagedDll
usesFunc
notation in order to be consistent with theLoading/Unloading events in
AssemblyLoadContext
.An alternative is to use
EventHandler
style recommended by these guidelines, and similar to certain other events in the same class.Related Topics
dotnet/corefx#32015 Native Library Loader API
The text was updated successfully, but these errors were encountered: