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

DllNotFoundException: Unable to load DLL 'google-ortools-native': The specified module could not be found. (Exception from HRESULT: 0x8007007E #4366

Open
shaileshgande opened this issue Sep 9, 2024 · 4 comments
Assignees
Labels
Duplicate Lang: .NET .Net wrapper issue OS: Windows Windows OS
Milestone

Comments

@shaileshgande
Copy link

shaileshgande commented Sep 9, 2024

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

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

What operating system (Linux, Windows, ...) and version?
Windows 11

What did you do?
Steps to reproduce the behavior:

  1. Create a console .NetFramework project targeting 4.6.2 version
  2. Install Google.Ortools via the Nuget package manager
  3. Use the "Solver.CreateSolver("GLOP")" line to get the solver object.
  4. Runtime exception is thrown:

System.TypeInitializationException: 'The type initializer for 'Google.OrTools.LinearSolver.operations_research_linear_solverPINVOKE' threw an exception
Inner exception 1:
TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
Inner Exception 2:
DllNotFoundException: Unable to load DLL 'google-ortools-native': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

What did you expect to see
Able to the solver object

What did you see instead?
runtime exeception

Note:
Nuget pacakage manager shows that the ortools package has dependency with .net framework 4.6.2.
So, ideally it should work with .net 4.6.2 and above
image

@Mizux
Copy link
Collaborator

Mizux commented Sep 9, 2024

IIRC net4.6.2 framewrok don't know how to parse project.csproj native library stuff so you need to load it manually...

related to:

note: Pet project to test combinatory:
https://github.com/Mizux/dotnet-native/actions/runs/10811556739

@Mizux Mizux added OS: Windows Windows OS Lang: .NET .Net wrapper issue labels Sep 9, 2024
@Mizux Mizux self-assigned this Sep 9, 2024
@Mizux Mizux added the Duplicate label Sep 9, 2024
@Mizux Mizux added this to the v10.0 milestone Sep 9, 2024
@Mizux
Copy link
Collaborator

Mizux commented Sep 9, 2024

Can you target .Net CORE instead ? i.e. net6.0 (LTS) or net8.0 (LTS) instead ?

ref:
https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core
https://dotnet.microsoft.com/en-us/platform/support/policy

@shaileshgande
Copy link
Author

Thanks! @Mizux for the response!
Loading the dll 'google-ortools-native.dll' manually helped to resolve the exceptions in .net framework.
However, additionally the prefer-32 bit checkbox had to be unchecked for me to resolve the 'BadImageFormat' exception. (#1185)

Quick question:
Is there any other way than loading the dll manually to able to work with a .Net Framework application?
note: I cannot target .net core or .net 6.0 or above.

@Mizux
Copy link
Collaborator

Mizux commented Sep 16, 2024

very long time ago we also shipped a runtime.json, maybe for .Net Framework user this one is mandatory to locate the runtime file ?
https://github.com/google/or-tools/blob/v6.10/ortools/dotnet/Google.OrTools/runtime.json.in

Will try to do some test in Mizux/dotnet-native project ASAP...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Lang: .NET .Net wrapper issue OS: Windows Windows OS
Projects
None yet
Development

No branches or pull requests

2 participants