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:
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!
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.