Emgu CV Unable to load DLL 'cvextern' in deployed project

£可爱£侵袭症+ 提交于 2019-12-04 05:54:41

问题


I'm using EmguCV for face detection in my ASP.NET project. When I run the project from Visual Studio, everything works correct.

Then I published release build via Folder profile and then just uploaded this published build to smarterasp.net.

Application is working in general. But when the application is trying to detect faces in images, an exception is throwed:

System.AggregateException: One or more errors occurred. ---> System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
   at Emgu.CV.CvInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
   at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
   at FaceDetection.FaceDetector.GetFaces(Bitmap img) in D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\FaceDetection\FaceDetector.cs:line 22
   at ImageModification.FaceBlurModificator.Modify(Image img) in D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\ImageModification\FaceBlurModificator.cs:line 21
   at FacelessBrowserTT.Controllers.HomeController.<>c__DisplayClass4_0.<PreparePage>b__1() in D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\FacelessBrowserTT\Controllers\HomeController.cs:line 81
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at FacelessBrowserTT.Controllers.HomeController.<PreparePage>d__4.MoveNext() in D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\FacelessBrowserTT\Controllers\HomeController.cs:line 86
---> (Inner Exception #0) System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
   at Emgu.CV.CvInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
   at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
   at FaceDetection.FaceDetector.GetFaces(Bitmap img) in D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\FaceDetection\FaceDetector.cs:line 22
   at ImageModification.FaceBlurModificator.Modify(Image img) in D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\ImageModification\FaceBlurModificator.cs:line 21
   at FacelessBrowserTT.Controllers.HomeController.<>c__DisplayClass4_0.<PreparePage>b__1() in D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\FacelessBrowserTT\Controllers\HomeController.cs:line 81
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()<---

What's interesting is that there're my local paths of Home Controller and other files in the exception:

D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\FacelessBrowserTT\Controllers\HomeController.cs
D:\Programming\C#Projs\FacelessBrowserTT_DIV_CONTAINER\FaceDetection\FaceDetector.cs
...

Maybe that's the reason? Why there're my local paths somewhere in the deployed application?

I have never deployed a project before, so it's 100% there's some stupid mistake I made. What am I doing wrong?


回答1:


The simple answer is, wherever your exe file is, ALL of the EmguCV DLLs AND OpenCV DLLs must be also. What goes on during development has absolutely no bearing on deployment.

I find convenient to put the EmguCV DLLs in the folder with my EXE and in a folder called x64 put all the OpenCV dlls. The x64 folder is ALSo in the same folder as your exe.

Doug



来源:https://stackoverflow.com/questions/45665606/emgu-cv-unable-to-load-dll-cvextern-in-deployed-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!