Skip to content

Fix Windows to look in Assembly Directory for 32bit dll. #68

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

Merged
merged 1 commit into from
Aug 6, 2020

Conversation

dellis1972
Copy link
Contributor

Commit 96eb5e3 introduced the use of DefaultDllImportSearchPathsAttribute
to add extra security when loading native libraries. This
works fine when the executable that is running is in the
same directory as the LibZipSharp.dll and the libzip.dll.

However when the executable has a different WorkingDirectory
as the LibZipSharp.dll this then causes the following
error.

System.DllNotFoundException: Unable to load DLL 'libzip'

This is because with the new attribute only Safe paths are searched.
So when we run this under MSBuild.exe for example, the Working
directory will definately NOT contain the 32bit libzip.dll.

The fix to to always set the location of the libzip.dll via
SetDllDirectory for both 32bit and 64bit processes.

Also bump to 1.0.18

Commit 96eb5e3 introduced the use of `DefaultDllImportSearchPathsAttribute`
to add extra security when loading native libraries. This
works fine when the executable that is running is in the
same directory as the `LibZipSharp.dll` and the `libzip.dll`.

However when the executable has a different `WorkingDirectory`
as the `LibZipSharp.dll` this then causes the following
error.

	System.DllNotFoundException: Unable to load DLL 'libzip'

This is because with the new attribute only Safe paths are searched.
So when we run this under MSBuild.exe for example, the `Working`
directory will definately NOT contain the 32bit `libzip.dll`.

The fix to to always set the location of the `libzip.dll` via
`SetDllDirectory` for both 32bit and 64bit processes.

Also bump to 1.0.18
@dellis1972 dellis1972 requested a review from grendello August 6, 2020 08:45
@dellis1972 dellis1972 merged commit 28b4639 into dotnet:master Aug 6, 2020
@dellis1972 dellis1972 deleted the fixwindowssearch branch August 6, 2020 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants