-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Can't load or-tools 9.6 library on windows, .NET6 #3747
Comments
Experiencing the same issue with versions 9.6 and 9.7, .NET Framework 4.8, Windows 11 22H2. I notice that google-ortools-native.dll is not copied to the application directory. When I do this manually, computation runs as expected. Is work ongoing to fix this issue? |
For release, on windows, we are generating nuget package using or-tools/tools/release/build_delivery_win.cmd Lines 130 to 132 in 1d696f9
Lines 316 to 317 in 1d696f9
Dev Note: |
I can confirm I am also having this issue with .NET Framework 4.8 on Windows 11 Pro 23H2 and or-tools version 9.7.2996/9.8.3296. google-ortools-native.dll does not get copied to the output directory on build. |
TLDR;The missing google-ortools-native.dll file issue can be resolved by explicitly setting the target runtime when building/running the example project. For example on Windows To build To run The target runtime can be changed to linux-arm64, linux-x64, osx-arm64, osx-x64, or win-x64 as required. Diagnosing the problemThe issue of the missing google-ortools-native.dll file in the build output directory when targeting .NET Framework 4.8 is due to using the dotnet build tool (created for .NET Core/.NET5+) to build a project/solution targeting the older .NET Framework versions. To diagnose this I downloaded the example project from this URL https://developers.google.com/optimization/install/dotnet/pkg_windows In the csproj file I changed the TargetFramework to net4.8 and used the PackageReference -> Google.OrTools version 9.8.*. I used the dotnet SDK version 6.0.417. Using the current build instructions (with a more verbose logging setting)
you can see that the RuntimeIdentifier (RID) that is resolved is win7-x86. This RID is used to try to restore native content from the transient dependency packages Google.OrTools.runtime.*, and there is no content for this particular RID in any of the packages (see https://learn.microsoft.com/en-us/dotnet/core/rid-catalog for more information on RIDs). To fix this issue one needs to specify the RID explicitly when targeting an older .NET Framework version. For example, on Windows, one can use
If one has the target framework of net6, and use the current build instructions
the build output directory contains a directory called runtimes that contains subdirectories for each runtime. In this case, the correct native library is located and loaded at runtime. |
The example repo: |
I greatly appreciate the detailed write-up, it is very useful for anyone on .NET 48 that can use the dotnet tool. Unfortunately the dotnet tool does not work with .NET 48 asp.net mvc projects and I am unable to add the runtime identifier to them. I tried adding the xml tag to the csproj but it had no effect (which makes sense given it is not and can't be an SDK style project). I implemented a manual build step that copies the file but wanted to post this in case anyone else is in a similar situation. |
I encountered a similar problem in AspNetCore (v.8) and OrTools 9.9.3963, and none of the above solutions helped. The problem was resolved by installing the latest Visual C++ Redistributable package from https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 |
Version: v9.6
Language: C#, .NET6
Solver: any solver
OS: Windows 11 21H2
CPU: Intel Core i7-1185G7
Downloaded example repo as zip from the installation page which still points to v9.5 and it worked fine. Updating it to v9.6 or creating a new project and installing or-tools 9.6 via nuget raises the following runtime exception:
Downgrading or-tools to 9.5 via nuget fixes the problem
The text was updated successfully, but these errors were encountered: