C# “Emgu.CV.CvInvoke”的类型初始值设定项引发异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/503427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The type initializer for 'Emgu.CV.CvInvoke' threw an exception
提问by
If anyone who use Emgu openCv wrapper in .net 3.5 framework,please tell me why this exception appears,Its inner exception is unable to load cxcore.dll.
如果有人在.net 3.5框架中使用Emgu openCv包装器,请告诉我为什么会出现这个异常,它的内部异常无法加载cxcore.dll。
回答by Jon Skeet
I suggest you turn on Fusion loggingand see where it's tryingto load cxcore.dll from, and check that you've got it in the right place.
我建议您打开 Fusion 日志记录并查看它尝试从何处加载 cxcore.dll,并检查您是否将其放在正确的位置。
回答by Kris Erickson
You don't have the right version of openCV installed, or you don't have the openCV dll's installed at all. The latest version of Emgu uses cxcore110.dll, previous version use cxcore100.dll. They have to either be in the directory your application is running, or in the path (probably %system32%). I had this problem a when I tried to get Emgu running.
您没有安装正确版本的 openCV,或者根本没有安装 openCV dll。Emgu最新版本使用cxcore110.dll,之前版本使用cxcore100.dll。它们必须位于您的应用程序正在运行的目录中,或者位于路径中(可能是 %system32%)。当我试图让 Emgu 运行时,我遇到了这个问题。
回答by kenny
I'm having the same problem. I setup Fusion logging and it wasn't helpful, for me. I'm running the assembly in the same directory as cxcore110.dll, so I'm stumped.
我有同样的问题。我设置了 Fusion 日志记录,但对我来说没有帮助。我在与 cxcore110.dll 相同的目录中运行程序集,所以我很难过。
Next, I loaded/copied all of the OpenCV DLLs in a directory in my path, same problem.
接下来,我在我的路径中的一个目录中加载/复制了所有 OpenCV DLL,同样的问题。
Found the solution after using dependency walker. It was working on any system that had VS2005 & VS2008. If you only have VS2008, then you'll need the Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)s]1.
使用dependency walker后找到解决方案。它适用于任何具有 VS2005 和 VS2008 的系统。如果您只有 VS2008,那么您将需要 Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)s] 1。
回答by Omar Osama
For Emgu CV version <= 2.1, this means the following dlls: cvXXX.dll, cvauxXXX.dll, cxcoreXXX.dll, highguiXXX.dll, opencv_ffmpegXXX.dll, mlXXX.dll and cvextern.dll where XXX is the OpenCV version number.
对于 Emgu CV 版本 <= 2.1,这意味着以下 dll:cvXXX.dll、cvauxXXX.dll、cxcoreXXX.dll、highguiXXX.dll、opencv_ffmpegXXX.dll、mlXXX.dll 和 cvextern.dll,其中 XXX 是 OpenCV 版本号。
For Emgu CV version >= 2.2 this means the following dlls: opencv_calib3dXXX.dll, opencv_contribXXX.dll, opencv_coreXXX.dll, opencv_features2dXXX.dll, opencv_highguiXXX.dll, opencv_imgprocXXX.dll, opencv_legacyXXX.dll, opencv_mlXXX.dll, opencv_objectdetectXXX.dll, opencv_videoXXX.dll where XXX is the OpenCV version number.
对于 Emgu CV 版本 >= 2.2,这意味着以下 dll:opencv_calib3dXXX.dll、opencv_contribXXX.dll、opencv_coreXXX.dll、opencv_features2dXXX.dll、opencv_highguiXXX.dll、opencv_imgprocXXX.dll、opencv_legacyXXX.dll、opencv_mlXXX.dll、openvideo_cvobjectXXX.dll .dll 其中 XXX 是 OpenCV 版本号。
copy these file and paste them in C:\WINDOWS\system32
复制这些文件并将它们粘贴到 C:\WINDOWS\system32
it works with me
它和我一起工作
回答by nagash
After trying all posible opencv_xxx combinations, what it worked for me was including the library npp32_42_9.dll. Hope it helps.
在尝试了所有可能的 opencv_xxx 组合之后,它对我有用的是包括库 npp32_42_9.dll。希望能帮助到你。
回答by Marc De Joya
This error happened to me. I added cxcore210.dll(for emgucv 2.1 version) which is originally located inside the bin folder.
这个错误发生在我身上。我添加了最初位于 bin 文件夹内的cxcore210.dll(用于 emgucv 2.1 版本)。
Then this caused a new error saying that I must also include the highgui210.dll(also for emgucv 2.1 version)...
然后这导致了一个新的错误,说我还必须包含highgui210.dll(也适用于 emgucv 2.1 版本)...
Then the problem was solved :)
然后问题就解决了:)
I hope it works for you too...
我希望它也适用于你......
回答by Babi
Here's how I could solve the problem: Copy the x86 (or x64 on 64-bit OS) folder address under "bin" folder where your Emgu is installed. Mine is: C:\Emgu\emgucv-windows-universal-gpu 2.4.9.1847\bin\x86
以下是我解决问题的方法:复制安装 Emgu 的“bin”文件夹下的 x86(或 64 位操作系统上的 x64)文件夹地址。我的是:C:\Emgu\emgucv-windows-universal-gpu 2.4.9.1847\bin\x86
Then paste this address here: Control Panel>System>Advanced System Settings>Environment Variables> in system variables click on "Path" and click edit > add a semicolon to the end of the string there and paste the address you've just copied to clipboard after that semicolon > click on the OKs.
然后在此处粘贴此地址:控制面板>系统>高级系统设置>环境变量>在系统变量中单击“路径”并单击编辑>在那里的字符串末尾添加分号并粘贴您刚刚复制的地址分号之后的剪贴板>单击确定。
回答by Ali Asgari
I had that error times and times. I was using EmguCV 2.4.9 and .Net framework 4.5. I checked many tutorials but didn't find the answer. At the end when i put the opencv files both from version 220 and 249 it worked!
我有那个错误的时间和次数。我使用的是 EmguCV 2.4.9 和 .Net 框架 4.5。我查了很多教程,但没有找到答案。最后,当我将版本 220 和 249 的 opencv 文件都放入时,它起作用了!
回答by Subodha Charles
Copy and paste all the unmanaged dlls in the bin folder of your EMGU installation to where your exe file is (Release or Debug folder of your project folder).
In my case, unmanaged dlls are at "C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\x86"
将 EMGU 安装的 bin 文件夹中的所有非托管 dll 复制并粘贴到 exe 文件所在的位置(项目文件夹的 Release 或 Debug 文件夹)。
就我而言,非托管 dll 位于“C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\x86”
回答by Jian
I installed EmguCV 2.9 recently. 64 bit application works fine. This exception showed up when I tried to use 32 bit platform (x86).
我最近安装了 EmguCV 2.9。64 位应用程序工作正常。当我尝试使用 32 位平台 (x86) 时出现此异常。
I realized that while following a tutorial to setup Emgu , I had set the "Path" in the system environment variables to .\x64 folder. For my case, it is C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\
我意识到在按照教程设置 Emgu 时,我已将系统环境变量中的“路径”设置为 .\x64 文件夹。就我而言,它是 C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\
To make the 32 bit application work, I changed the "Path" variable to .\x86 folder, restart the computer. The draw back is 64 bit solution will no longer work.
为了使 32 位应用程序工作,我将“路径”变量更改为 .\x86 文件夹,重新启动计算机。缺点是 64 位解决方案将不再有效。
The ideal solution is to copy all the DLL files from .\x86 or .\x64 to where the executable locates. For my case, because I am using LabVIEW + .NET DLL, the LabVIEW gets a copy of the DLL into its cache folder, so the temporary solution for the easy of development is to change "Path" variable. When I distribute the final binary executable, I will copy the matching DLL files.
理想的解决方案是将 .\x86 或 .\x64 中的所有 DLL 文件复制到可执行文件所在的位置。就我而言,由于我使用的是 LabVIEW + .NET DLL,LabVIEW 将 DLL 的副本放入其缓存文件夹中,因此为便于开发,临时解决方案是更改“路径”变量。当我分发最终的二进制可执行文件时,我将复制匹配的 DLL 文件。