视频图像处理系列索引 || Arcgis/Engine/Server开发索引 || Web Map Gis开发索引 || jquery表格组件 JQGrid索引
WPF MVVM模式开发实现简明教程索引 || ArcGIS Runtime WPF(.net C#)开发简明教程索引

"Emgu.CV.CvInvoke”的类型初始值设定项引发异常 解决办法

 

 

系统win7 32位,只在这一台电脑上出现这种问题,已知VS编译是X86,在数台电脑上测试都正常。

 

后来把opencv的dll路径例如 E:\...\x86  加入到系统环境变量中就正常了。

 

emgucv安装里opencv的dll路径是这个样子 C:\Emgu\emgucv-windows-universal 3.0.0.2157\bin\x86,发布时把bin下的dll包括x86等拷贝到程序安装目录下。

 

但很奇怪这一台电脑无法使用,理论上emgucv发布不需要环境变量的。

还是要继续研究,欢迎知道的解答下。

 

 

 

官方解释:

The type initializer for 'Emgu.CV.CvInvoke' threw an exception.

If you see this exception, please check the following

Have you installed MSVCRT?

  • For Version 3.0+, the required vcrt dlls are included in the "x86" and "x64" folder. You will be ready as long as you copy all the unmanaged dlls in the "x86" and "x64" folder to the folder of executable.
  • For Version 2.4+, the bundled OpenCV binary is build with Visual Studio 2010, you will needs to installed MSVCRT 10.0 SP1 x86 or MSVCRT 10.0 SP1 x64 to resolve the dependency issue.
  • For Version 2.0+, the bundled OpenCV binary is build with Visual Studio 2008, you will needs to installed MSVCRT 9.0 SP1 to resolve the dependency issue.
  • For Version 1.5, the bundled OpenCV pre1.1 binary is build with Visual Studio 2005, you will needs to installed MSVCRT 8.0 SP1 to resolve the dependency issue.

Have you copied the OpenCV dlls to the execution directory?

  • Make sure the unmanaged DLLs are in the execution directory.
    • For Emgu CV version >=2.4.2, this means the "x86" and "x64" folder and all the dlls within the folders. The folder names and file structures should not be altered when deploying with the application.
    • For EMGU CV version 2.4 cudart64_42_9.dll, cvextern.dll, npp64_42_9.dll, opencv_calib3dXXX.dll, opencv_contribXXX.dll, opencv_coreXXX.dll, opencv_features2dXXX.dll, opencv_flannXXX.dll, opencv_highguiXXX.dll, opencv_imgprocXXX.dll, opencv_legacyXXX.dll, opencv_mlXXX.dll, opencv_nonfreXXX.dll, opencv_objectdetectXXX.dll, opencv_videoXXX.dll,</code?> where <code>XXX is the OpenCV version number.
    • For Emgu CV version 2.2, 2.3 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.
    • For Emgu CV version <= 2.1, this means the following dlls:cvXXX.dll, cvauxXXX.dll, cxcoreXXX.dll, highguiXXX.dll, opencv_ffmpegXXX.dll, mlXXX.dllcvextern.dll where XXX is the OpenCV version number.
  • The best way to set up your project is:
    • Copy the unmanaged DLLs to your project folder
    • Right click on the project, click Add->Existing Item and select all unmanaged DLLs. Add them to the project.
    • For each of the included Dlls, left click on it, find the "Copy to Output Directory" option and select "Copy if newer"

Are you missing any dependency?

Download Dependency Walker and use it to open the "cvextern.dll" file. Check if any dependency is missing.

I have checked all of above but I still got the Exception

In this case, please try to build and run the examples. After building the examples, try to run the "Hello World" Program.

If "Hello World" runs without any problem, compare it with you project, find the difference in configuration and fix it.

If "Hello World" get the same "The type initializer for 'Emgu.CV.CvInvoke' threw an exception." message, try to find out the InnerException and report it to the discussion forum

posted @ 2016-04-27 16:30  jhlong  阅读(12779)  评论(4编辑  收藏  举报
海龙的博客 jhlong@cnblogs 版权所有© 转载请注明链接.有用请推荐一下
代码全部经过本人测试,但不保证复制粘贴就正常运行,更不保证能解决你的问题,请结合前后代码及描述理解后修改和使用