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

江枫思渺然 提交于 2019-12-01 00:06:30

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.

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.

copy these file and paste them in C:\WINDOWS\system32

it works with me

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

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.

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.

Then this caused a new error saying that I must also include the highgui210.dll (also for emgucv 2.1 version)...

Then the problem was solved :)

I hope it works for you too...

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.

After trying all posible opencv_xxx combinations, what it worked for me was including the library npp32_42_9.dll. Hope it helps.

I suggest you turn on Fusion logging and see where it's trying to load cxcore.dll from, and check that you've got it in the right place.

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.

Next, I loaded/copied all of the OpenCV DLLs in a directory in my path, same problem.

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.

If you already did the dll setup and still get the exception try as follows: Go to Project Properties -> Application -> Target Framework, and change it to NET. Framework 4 and click 'Yes'. Run again your application, and it should work just fine.

It took me a while to figure out why this was happening in my case as none of the above solutions solved the problem. It turned out that I had Windows 10 Pro N installed which lacks media features. After installing the Media Feature Pack it worked.

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!

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"

I installed EmguCV 2.9 recently. 64 bit application works fine. This exception showed up when I tried to use 32 bit platform (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\

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.

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.

In my case, adding these files under the bin\release solved this issue: npp32_42_9.dll and cudart32_42_9.dll

It took me around 2 hours to conclude this :)

I have installed OpenCv2.3.1 before and yesterday i installed the last version of EmguCV3.0 (also tried 2.9 ) but it gave that error.

all the solutions that i tried didn't work than I installed EmguCV 2.3 and its solved. i think version of EmguCV and opencv important for solution.

Wasim Akbar

After trying a lot things, if your .dll files are all correctly placed and only version problem exits try following simple steps:

  1. Open properties of created project
  2. Go to build section
  3. Change platform target to "Any CPU"

Save and rebuild project.

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