-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
NativeAOT fails to resolve PInvoke in System.Data.SqlClient
#89874
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsSee #89782 (comment) for details. Repro steps:
|
@MichalStrehovsky any ideas - I can try looking into it, but I don't know where to start really. |
These search flags get passed correctly into Lines 37 to 40 in a743d60
DllImportSearchPath.AssemblyDirectory and so we are left with just DllImportSearchPath.System32 .
The problem happens here: Lines 97 to 101 in a743d60
We effectively ignore |
That comment reads wrong - NativeAOT already made the decision to put native dependencies next to the exe (instead of the assembly the PInvoke came from), so treating |
This was written as "better to be conservative than to get an MSRC later". How does CoreCLR single file compute "the location of the assembly", is |
And how does this distinction look like for the "NativeAOT'd shared library" case? |
Single-file actually adds the app directory to NATIVE_DLL_SEARCH_DIRECTORIES: #42876, #42772 |
I think this is something we should try to fix for .NET 8. I'll be out for the next week, so if somebody could pick this up? |
The coreclr test cases are: runtime/src/tests/Interop/NativeLibrary/API/NativeLibraryTests.cs Lines 176 to 177 in fa78033
runtime/src/tests/Interop/DllImportSearchPaths/DllImportSearchPathsTest.cs Lines 30 to 31 in fa78033
NativeAOT would need a variation of that though. They both use |
I'll take a look at this. |
See #89782 (comment) for details.
The failure is really weird - I can confirm that the native dll is next to the AOT compiled app.
Non-AOT version of the app can load the dll just fine (it fails later on for me, but that's not the issue here).
I also tried just a simple app with a PInvoke (using Libuv package and calling into it) and that works just fine even with NativeAOT.
Repro steps:
https://github.com/dotnet/runtime/files/12243049/sqlClient.zip
Publish as AOT and run on win-x64.
The text was updated successfully, but these errors were encountered: