opencvsharp: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.

This looks to be a great library/wrapper, and I can setup and run the console app samples with no problem. However, I am trying to use this in a WebApiApplication that calls a custom library DLL, and am running into:

Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found.

My project is structured such that the WebApiApplication calls a DLL form another project I created (and this is where the OpenCVSharp3 calls happen), so I have installed OpenCVSharp3-AnyCPU on both projects (MyWebApiProject and MyLibraryProject). I am using the NuGet install method, for OpenCVSharp3-AnyCPU (so OpenCV 3.0, as of the October 19, 2015 push to NuGet).

When I build and run the project, my bin directory(s) look like:

**MyWebApiProject**
Bin
│
├───dll
│   │
│   ├───x86
│   │   ├───msvcp120.dll
│   │   ├───msvcr120.dll
│   │   ├───opencv_ffmpeg300_64.dll
│   │   ├───opencv_world300.dll
│   │   └───OpenCvSharpExtern.dll
│   │
│   └───x64
│       ├───msvcp120.dll
│       ├───msvcr120.dll
│       ├───opencv_ffmpeg300_64.dll
│       ├───opencv_world300.dll
│       └───OpenCvSharpExtern.dll 
│   
├───OpenCvSharp.dll
├───OpenCvSharp.Blob.dll
├───OpenCvSharp.Extensions.dll
├───OpenCvSharp.UserInterface.dll
│
├───MyLibraryProject.dll
│
└───Additional DLL and binary files 

**MyLibraryProject**
Bin
│
├───dll
│   │
│   ├───x86
│   │   ├───msvcp120.dll
│   │   ├───msvcr120.dll
│   │   ├───opencv_ffmpeg300_64.dll
│   │   ├───opencv_world300.dll
│   │   └───OpenCvSharpExtern.dll
│   │
│   └───x64
│       ├───msvcp120.dll
│       ├───msvcr120.dll
│       ├───opencv_ffmpeg300_64.dll
│       ├───opencv_world300.dll
│       └───OpenCvSharpExtern.dll
│
├───OpenCvSharp.dll
├───OpenCvSharp.Blob.dll
├───OpenCvSharp.Extensions.dll
├───OpenCvSharp.UserInterface.dll
│
└───Additional DLL and binary files 

So to me, everything looks like it is in place.

However, the first time I call into an OpenCVSharp3 method (such as: Mat image = Mat.FromImageData(buffer, ImreadModes.Color);), I get the `Unable to load DLL ‘OpenCvSharpExtern’ error.

Does anyone have any idea how to use OpenCVSharp3 in a web application? Or could it be that my custom DLL is messing things up?

Any help would be greatly appreciated. I’m at a loss here.

Also, if it matters, I am using Visual Studio 2015 on .Net-Framework 4.5. ~Brett

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I have ever used OpenCvSharp in some ASP.NET MVC5 WebApi projects. I also bother about this problem. 😕

Please try to copy the native DLL files (opencv_*.dll, msvc*.dll and OpenCvSharpExtern.dll) from Bin\dll\[x86 or x64]\ to Bin\, or add the location of native DLLs to the PATH environment variable.

I Got the same error and installed from NuGet “opencvsharp3-AnyCPU” and it removed the problem for me

Working for me is to copy OpenCvSharpExtern.dll to debug folder.

\Documents\Visual Studio 2017\Projects\emgucv1\emgucv1\bin\Debug * put here