-
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
Exception when loading native dlls from the application path when using AssemblyDirectory and System32 as the DllImportSearchPath #111825
Comments
Tagging subscribers to this area: @dotnet/interop-contrib |
@elinor-fung can you take a look? |
We end up loading with runtime/src/coreclr/vm/nativelibrary.cpp Line 708 in 1da2ea4
I'm not sure why it only fails in the case where it needs to load a dependency of the library, but we should probably remove any I think that is also true for the case where the DllImport specifies an absolute path: runtime/src/coreclr/vm/nativelibrary.cpp Lines 690 to 698 in 1da2ea4
|
Description
There seems to be an issue when loading a native dll in the application path that depends on a native dll also in the application path when using
DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.System32
as the search path. When both of those scenario occurs, it'll throw an exception that the dll could not be loaded. This issue is not reproducible when using onlyDllImportSearchPath.AssemblyDirectory
or if a native dll does not have a dependency on another native dll in the application path. This also doesn't seem to affect native dlls shipped in a runtime pack because the .Net host seems to include a custom search path for the runtime packs.This is a bug I found while investigating a problem when running WPF unit tests, see dotnet/wpf#10304 (comment) for more info. I'm not sure if it's the expected behavior, a bug or if I simply misunderstood the bug in WPF.
/cc @dipeshmsft
Reproduction Steps
Expected behavior
Methods Test1WithoutSystem32 and Test1WithSystem32 should both succeed.
Actual behavior
Methods Test1WithoutSystem32 succeeds and Test1WithSystem32 fails.
Regression?
I tested using .Net 6 through .Net 9 and they all have the same behavior.
Known Workarounds
Change the DllImportSearchPath.
Configuration
.Net 9.0
Windows 11 x64
Don't know if it is specific to my configuration.
Other information
No response
The text was updated successfully, but these errors were encountered: