问题
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!
回答1:
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.
回答2:
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.
回答3:
From your error description and checks you already performed, it seems like that you have not installed MSVCRT.
回答4:
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
- i installed
Visual C++ 2010 x86
. - 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.
回答5:
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.
来源:https://stackoverflow.com/questions/10930610/opencv-unmanaged-dlls-not-found-asp-net