What can I do if "the type initializer for 'emgu. cv. cvinvoke' threw an exception &#

Source: Internet
Author: User
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 2.0 +, the bundled opencv 2.0 binary is build with Visual Studio 2008, you will needs to installedMsvcrt 9.0 SP1To resolve the dependency issue.
    • For version 1.5, the bundled opencv pre1.1 binary is build with Visual Studio 2005, you will needs to installedMsvcrt 8.0 SP1To 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.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, release, opencv_corexxx.dll, release, opencv_highguixxx.dll, release, release, opencv_mlxxx.dll, release, opencv_videoxxx.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 attached ded DLLs, left click on it, find the "Copy to output directory" option and select "copy If newer"
Are you running a 32-bit OS?

The Windows Installer is only available for 32-bit windows. If you are using a 64-bit OS, there are three possible ways to resolve this issue:

    • You can download the 64bit binary only zip package from SourceForge and add it to your project.
    • You can also recompile opencv from source for 64-bit platform. See the instruction for building from SVN
    • Alternatively you can force your. NET application to run in 32bit mode, even on a 64-bit OS. To do this, in the configuration page of your executable project, select platform target'X86'.
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.