-
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
Document how unmanaged libraries are loaded with AssemblyLoadContext #16958
Comments
Based on the Interop Libraries that are being used in Corefx, I see that the Library names have the .dll appended to them. https://github.com/dotnet/corefx/blob/master/src/Common/src/Interop/Windows/Interop.Libraries.cs Is this bug specific to a sni.dll? Why do the other dll imports with the extension appended not cause any issue? |
Then I guess this discussion should be broader. It was my understanding that coreclr took care of appending .dll/.so/.dylib based on the platform. dotnet/coreclr#1248. Accordingly, managed code shouldn't need ".dll" explicitly in the unmanaged library name. Since this appears to be broader than just SqlClient, this issue could probably be merged with the disucssion of this behavior in other places, such as https://github.com/dotnet/coreclr/issues/930 or https://github.com/dotnet/coreclr/issues/444. Or perhaps this can be considered a bug on the |
@joshfree can you direct this issue accordingly? |
It doesn't need it, but there's nothing wrong with providing it. I don't see a problem here.
What's the buggy behavior? Isn't it just passing through the name of the library that was specified? |
The behavior that seems odd is that the parameter |
Looking at NDirect::LoadLibraryModule, the call made to AssemblyLoadContext.LoadUnManagedDll happens before CoreCLR interop layer attempts extension name processing. @adityamandaleeka Do you want to look into how to account for extension normalization before AssemblyLoadContext is invoked? |
The prefix/suffix logic we do in the DLL import code only adds the prefix and/or suffix to the name provided. If you PInvoke with |
The prefix/suffix logic seems to work fine when relying on the default load behavior. But I'm trying to implement the abstract class
Which is true? Right now, it depends on what was in DllImport, which can vary. I would have expected:
unmanagedDllName never includes .dll, .dylib, .so etc
unmanagedDllPath always contains .dll, .dylib, .so etc |
I understand. Right now I believe that the string is passed through the system essentially untouched. Your suggestion ( Consider the case where the user has named their native binary with a non-standard extension, such as using 'foo.dll' on a Mac. If we cut off the extension, it will be up to the host to somehow figure out what to do in that case right? |
After considering this, I think perhaps the better solution is leave the implementation as is, but just fix up API docs to make it clear that p/invoke essential flows through directly to the assemblyloadcontext call. The less magic the better. |
@natemcmaster Agreed. 👍 |
It looks like we need to improve our documentation around this. @karelz how should we track documentation issues? |
'documentation' label is the best at this moment for API docs. |
Is this superseded now by |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
This issue will now be closed since it had been marked |
On Windows, System.Data.SqlClient currently p/invokes to a native component sni.dll via DllImport
[DllImport("sni.dll")]
. This is inconsistent with other Dllimport calls in corefx that do not include the ".dll" extension in the native dll name. This causes inconsistent behavior in other parts of the stack.e.g.
AssemblyLoadContext.LoadUnmanagedDll(string unmanagedDllName)
is called withunmanagedDllName == "sni.dll"
, but for other libraries the extension is left off. This means AssemblyLoadContext is usually implemented to look for"sni"
, not"sni.dll"
.cref https://github.com/dotnet/cli/issues/2289#issuecomment-208655706
Update
Decided the behavior is fine, but we should document it as it's non-obvious.
The text was updated successfully, but these errors were encountered: