EmguCV TypeInitializationException

ⅰ亾dé卋堺 提交于 2019-11-27 04:51:28
rkmax

After experiencing this same problem for a while, I found the instructions for solving this (TypeInitializer Exception) are incomplete.

  1. For a basic app, you need cvextern.dll, Emgu.CV.dll, Emgu.CV.UI.dll, Emgu.Util.dll in the .EXE's directory.

  2. You need a x86(x64) dir in the .exe directory and inside "x86" dir you need 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 and cudart32_42_9.dll, npp32_42_9.dll, opencv_flann240.dll

The app will work as soon as you include all of the required DLLs.

I'm using Emgu 3.0 64 bit and the only thing i need to do to fix this problem is change the build type in my project into x64.

Right click on your project's name -> Properties -> Build -> Platform Target -> x64

refer to http://www.codeproject.com/Articles/257502/Creating-Your-First-EMGU-Image-Processing-Project

hope it helps someone.

Another case that happened to me was that I had a NuGet package that was installed but not loaded for my project so the references looked good but at run-time, I got the TypeInitializationException.

-manage NuGet packages

-clock manage on the package

-check the box with the current project.

This problem also occurs if you are using OpenCV DLL compiled with GPU support but your PC doesn't have a GPU, e.g. if you are using a portable computer with Intel graphics chipset.

In this case you can use the older version 2.4.0 which still offers DLL without GPU support:

https://sourceforge.net/projects/emgucv/files/emgucv/2.4.0/libemgucv-windows-x64-2.4.0.1717.zip

Just copy the cvextern.dll file from x64 folder if you are using 64bit OS and then copy it to the debug folder of your project.

Note: Do it manually because "add existing item" doesn't copy it.

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