DllNotFoundException for libz3.dll when using Z3 via nuget

0

I use Z3 via NuGet package in my .NET Core 2.1 project and recently tried to update from version 4.5.0.1 to 4.8.1. Then I reverted back to 4.5.0.1 and got this exception at context creation:

using(var ctx = new Microsoft.Z3.Context())
{

}

System.DllNotFoundException: Unable to load DLL 'libz3.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I checked the following:

  • my app is compiled for x64 and I use z3x64win package,
  • both libz3.dll and Microsoft.Z3.dll are stored in %userprofile%\.nuget\packages\z3x64win\4.5.0.1\lib,
  • tried to add this path to the PATH environment variable as described here but it did not help,
  • tried to manually save libz3.dll and Microsoft.Z3.dll to bin directory of the project but the problem persists.

Are there any other necessary steps to refer Z3?

c#
.net-core
nuget
z3
asked on Stack Overflow Dec 9, 2018 by FIL • edited Dec 9, 2018 by FIL

2 Answers

0

Back in the days I remember having these problems with Z3 and often it worked by trying the following:

  • Remove and reset your Microsoft.Z3.dll reference completely. Make sure the csproj file is clean from references before adding the reference again.
  • Re-download or get Z3 dll's so that you are hundred procent sure they match and that VS or your environment don't use cache.

  • Are you sure both libz3.dll and z3.exe is in your PATH?

answered on Stack Overflow Apr 15, 2019 by Behrouz Talebi
0

There is now an official .NET Core Z3 NuGet package which should solve all your issues: https://www.nuget.org/packages/Microsoft.Z3.x64/

answered on Stack Overflow Jun 4, 2019 by ahelwer

User contributions licensed under CC BY-SA 3.0