Or-tools: google-ortools-native.dll not found

Created on 14 Jan 2020  路  10Comments  路  Source: google/or-tools

What version of OR-tools and what language are you using?
Version: master
Language: C#

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
Routing Solver

What operating system (Linux, Windows, ...) and version?
Windows Version 1909 Build 18363.535

What did you do?
1) I was using the nuget package for the google or tools with dotnet core 2.2, where everything worked fine.
2) Upgraded to dotnet core 3.1
3) Running my program throws this:
System.TypeInitializationException : The type initializer for 'Google.OrTools.ConstraintSolver.operations_research_constraint_solverPINVOKE' threw an exception. ---- System.TypeInitializationException : The type initializer for 'SWIGExceptionHelper' threw an exception. -------- System.DllNotFoundException : Unable to load DLL 'google-ortools-native' or one of its dependencies: Das angegebene Modul wurde nicht gefunden. (0x8007007E) at Google.OrTools.ConstraintSolver.operations_research_constraint_solverPINVOKE.new_RoutingIndexManager__SWIG_0(Int32 jarg1, Int32 jarg2, Int32 jarg3) at Google.OrTools.ConstraintSolver.RoutingIndexManager..ctor(Int32 num_nodes, Int32 num_vehicles, Int32 depot)

What did you expect to see
No Exception

Anything else we should know about your project / environment
Copying the google-ortools-native.dll from the nuget package to System32 solved the issue

Also this issue did't occour on linux.

Bug .NET Windows Routing Solver

All 10 comments

Which TargetFramework did you use in your .csproj ?

Wow thank you for the fast reply

I think netcoreapp3.1

My csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <LangVersion>8</LangVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Google.OrTools" Version="7.4.7247" />
    </ItemGroup>
</Project>

can you try:

<TargetFramework>netcoreapp2.1</TargetFramework>
<RollForward>LatestMajor</RollForward>

and did you get some warning/errors at build time ?

I did not get any warnings from the google or tools namespace.

Since this project is dependent on others, which I already have migrated to dotnet core 3.1,

<TargetFramework>netcoreapp2.1</TargetFramework>
<RollForward>LatestMajor</RollForward>

prevents the whole build.
However I will set up a small standalone without such cross-dependencies and then try it out.
I hope I get this done today or tomorrow.

For your information the last release 7.4.7247 only contains netstandard2.0 library while the incoming v7.5 release should contains both netstandard2.0 and netstandard2.1 library. I still don't know exactly how it is related to netcoreapp3.1 but it might help (need to setup a vm with only the .Net Core SDK 3.1 to verify).

Also the google-ortools-native.dll is provided by the sub package Google.OrTools.runtime.win-x64.7.4.7247.nupkg so maybe we still have something wrong on window to load this package which contains the library in a native sub-directory

Turns out cloning my code to another directory and trying it from there made the error go away.

But I seriously don't understand how this can happen, I rebuild and cleaned the solution, even deleted the bin and obj directories, but still in the error persists.
However I tried to reproduce the error in a smaller project but it just wouldn't appear, so I cloned the code "causing" it in another directory and it just worked.
(I even checked cloning it into a directory wich have a longer path, than the original, just to be sure...)

Anyway, thank you very much for your fast replies!

Edit: Not even git clean -xdf fixed it at the old location

Edit2: Seems that I have failed validating the path length... It seems to happen, if the directory path of the project is beyond a certain length

Glad you was able to fix your issue !

Thank you also to have taken the time to share your feedback with the community !

I have the same issue, but my local PC is working. only this error comes when I deploy it to Azure. Do I have to do any extra step?

@gmenaka see answer in your cross posting -_-

Was this page helpful?
0 / 5 - 0 ratings