Skip to content
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

Add library folders to DLL search path on windows #1555

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

glopesdev
Copy link
Member

Starting from Windows 8 and Windows 7 SP1 KB2533623, Microsoft introduced new API enhancements for securely loading external native libraries.

The new API defines a process wide DLL search path which is modified only by direct calls to OS-specific functions. Modern .NET libraries that declare the DefaultDllImportSearchPath attribute set to DllImportSearchPath.SafeDirectories will use only this DLL search path to find native libraries and ignore the directories in the PATH environment variable set by the bootstrapper, which would ultimately lead to binding failures of native dependencies.

To workaround this, the bootstrapper now calls AddDllDirectory on Windows for each active native library folder when bootstrapping the environment.

Adding the same folders to the PATH environment variable is still required for compatibility with libraries relying on the default legacy p/invoke DLL import.

Fixes #1549

@glopesdev glopesdev added the fix Pull request that fixes an issue label Sep 13, 2023
@glopesdev glopesdev added this to the 2.8.1 milestone Sep 13, 2023
@glopesdev glopesdev merged commit 97b20bd into bonsai-rx:main Sep 13, 2023
@glopesdev glopesdev deleted the issue-1549 branch September 13, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Pull request that fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding native library folders to the process DLL search path
1 participant