0

For a project I am working on, I need to solve a mathematical model. I chose to do this using Microsoft.Solver.Foundation and the SolverFoundation.Plugin.LpSolve plugin. Both associated .dll files for these extension seem to work fine, as VS2015 recognizes and references them without a problem and compiles and runs my program without errors.

This is however up untill I try to actually solve my optimization, which needs "lpsolve55.dll" to work. I have downloaded this dll and put it in my project's bin/Debug folder, but for some kind of reason VS2015 just doesn't recognize it. I.e.

  • I can't reference it by simply browsing to it from my "Add Reference" tab.
  • It's impossible to (un-)register it via the regsvr32 cmd-prompt application, as it doesn't have any DLL (Un-)registry entry points.
  • The TlbImp.exe cmd-prompt application can't handle it.

So basically, after discovering the above (after trying the most-common internet solutions), I still feel quite dissatisfied to get the error message while I try to solve the optimization -

Unable to load DLL 'lpsolve55.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The wierd part is also that I have another project in which I solve a similar problem, where there are absolutely no problems at all using lpsolve55.dll....

Some quick facts:

  • I reference .NET framwork 4.5.2. I have changed it to 4.5 as well as 4.0, but this didn't change anyting.
  • For as far as I can tell, the bin/debug folder of my projects are identical.
  • I am working on a fully updated windows 10 OS, 64 bits, while using visual studio 2015.

My question would thus be whether or not some of you have encountered a similar problem and if you were able to solve it in some way.

Highly appreciated!

Dr.Ripper
  • 89
  • 8
  • 1
    if `lpsolve55.dll` is a 32-bit dll you might need to compile your project as a 32 bit project. – Sam I am says Reinstate Monica Jul 25 '16 at 23:03
  • 1
    and how are you accessing that dll from code? are you using ` [DllImport]`? is it used by another dll you're referencing? – Sam I am says Reinstate Monica Jul 25 '16 at 23:05
  • Thank you both for thinking with me. As far as the 32-bit possibility, i don't suspect this to be a problem. The other project builds in "Any CPU"-mode, as well as the project I am working on currently and there are no compiler differences as far as settings is concerned. As for the Dllimprot, i don't use it, because lpsolve55.dll is referenced by one of the other projects (i believe it's SolverFoundation.Plugin.LpSolve, which is recognized perfectly. Perhaps I can see how to make it find LpSolve55, but I believe this is an error that is not unique for my specific dll. – Dr.Ripper Jul 26 '16 at 05:28

1 Answers1

1

After some careful analysis, I have found the answer to the problem. To be honest, as most things are, it was quite simple in the end. The lpsolve55.dll wasn't recognized because I didn't have my new bin-folder in the Path, which I did have with my old project. I simply forgot.

On a further note however, after the lpsolve55.dll directory was added to the path, I still got an error telling me there was no model to be found that could solve my directive. Since the error occured when I was calling the LPSolverDirective(), some research landed me on the following page:

http://lpsolve.sourceforge.net/5.5/MSF.htm

Above page gives a complete and stable way of how to acces lpsolve55.dll using the LPSolverPlugin straight out of Microsoft.Solver.Foundation.dll. After following the method in the link that involves editing my projects' bin/Debug and bin/Release folders, I got the LP model up and running within no-time.

Morale of the story - read the documentation. I am a bit of a beginner in programming entire multi-project solutions and using customly-added dlls, but hopefully this helps someone else experiencing the same. In the end, I learned a lot by simply trying different methods of getting it to work, so no time was wasted.

Dr.Ripper
  • 89
  • 8