5

We are building a web application (C# .NET) that uses unmanaged libraries in the form of the Emgu opencv wrapper. We are forcing the build to be in 32-bit (x86), and we are using the 32-bit version of Emgu.

All this works nice on local builds, but when being published to our webserver the openCV Dll(s) fail to load:

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

System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'opencv_core240': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Emgu.CV.CvInvoke.cvRedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
   at Emgu.CV.CvInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IPL_DEPTH depth, Int32 channels)
   at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
   at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
   at Emgu.CV.Image`2..ctor(Bitmap bmp)

I tried the following things that I've found on stackoverflow and other sources:

  • Put the unmanaged Opencv Dll's in a seperate directory and put the path to this directory in the path environment variable, and restart the webservice.
  • Tested whether the server config allows for unmanaged code execution (yes)
  • Putting the unmanaged Opencv Dll's in system32\inetsrv and SysWOW64\inetsrv directories
  • Puting the unmanaged Opencv Dll's in a subdirectory 'x86' in the before mentioned folders

I understand this: http://msdn.microsoft.com/en-us/library/ms366723.aspx

is the reason of all trouble, however I do not understand why editing the path variable to include the correct path containing the Dll's doesn't solve anything.

Last useful post about this issue was in 2008, however no fool-proof solution has ben offered yet, so all the help is much appreciated!

Arthur
  • 138
  • 5
  • 12
  • Are the DLL's registered on the Development machines? i.e via regsvr32 Is the application pool set to run in 32BIT mode? – Mike Miller Jun 07 '12 at 11:16
  • DLL's have not ben registered on the development machines (so the situation is the same on development and webserver), and the application pool is set to allow 32bit apps (IIS7) – Arthur Jun 07 '12 at 13:16
  • if you use Depends on opencv_core240.dll are all the dlls listed available on the web server? – Mike Miller Jun 07 '12 at 13:21
  • Depends complains about not finding: MSVCP100.dll MSVCR100.dll, however after installing the VS2010 redist package (x86) http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84 - still nothing – Arthur Jun 07 '12 at 13:30
  • Unfortunately not, we ended up removing any reference to this library and using a different approach for this altogether. – Arthur Jul 03 '12 at 12:46
  • Such a shame; EMGUCV+OpenCV are great packages, but plagued by DLL-hell. Why can they not provide a coherent set of DLLs, in one single folder, that all work togehter? – smirkingman Mar 18 '14 at 22:22

5 Answers5

2

Make sure tbb.dll is also in the path, as opencv_core240.dll has a dependency on this. You can find tbb.dll under opencv/build/common/tbb.

user838914
  • 21
  • 3
  • Thank you, I had the same problem with OpenCvSharp 2.4 (instead of Emgu, and on a local machine) and this solved the problem for me. – Phasma Sep 25 '12 at 11:12
1

In my case "npp32_xx_x.dll" (xx_x is version no, 32 is the 32bit architecture) solved the problem. So you can try putting this dll to your projects out put folder for win apps and equivalent folder in web apps. The dll is Nvidia Cuda NPP Library.

Rik
  • 11
  • 3
0

From your error description and checks you already performed, it seems like that you have not installed MSVCRT.

Luca Del Tongo
  • 2,702
  • 16
  • 18
  • Thanks for your reply, however I checked and MSVCRT is installed on the webserver. – Arthur Jun 07 '12 at 13:16
  • Create an x86 folder inside your bin folder and try to copy opencv dlls such as opencv_core240.dll and the others there.That could fix module not found error. – Luca Del Tongo Jun 07 '12 at 22:42
  • Should've mentioned that earlier - but I tried that as well, without any luck unfortunatly – Arthur Jun 08 '12 at 07:06
0

I faced the same problem few days back, I tried everything in my knowledge, but nothing helped to fix the issue. EmguCV works fine in my local 64bit Windows 8 pc but the server (Windows Web Server 64bit).

But the problem was fixed after i did some truly random stuffs as follows: The server has Visual C++ 2008 Runtime previously installed, but again

  1. i installed Visual C++ 2010 x86.
  2. Repaired Visual C++ 2008 x86 Runtime installation

and that fixed the problem. I can't explain how this happened, but i'm happy that the problem solved after two days of random experiment.

Gonzalo.-
  • 12,512
  • 5
  • 50
  • 82
undefined
  • 2,939
  • 4
  • 23
  • 35
0

To solve this problem put nvcuda.dll in /bin folder on web server. Be sure nvcuda.dll must be x86 Architecture is the same as the server, or x64 if web server has x64 Architecture.

In future see other dependences in Dependence Walker http://www.dependencywalker.com/and put this dll's with parent libraries.

Chaos
  • 11,213
  • 14
  • 42
  • 69