The type initializer for "Emgu.CV.CvInvoke" throws an exception workaround

Source: Internet
Author: User












System Win7 32-bit, only on this computer, this problem occurs, known as vs compilation is X86, test on several computers is normal.






The OpenCV DLL path, such as E:\...\x86, was later added to the system environment variable.






EMGUCV Installation OpenCV DLL path is this look C:\Emgu\emgucv-windows-universal 3.0.0.2157\bin\x86, release the DLL under the bin including x86 and other copies to the program installation directory.






But it is strange that this computer cannot be used, in theory EMGUCV release does not require environment variables.



Still want to continue research, welcome to know the answer under.












Official explanation:


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 is included in the "x86" and "x64" folder. You'll 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 are build with Visual Studio, you'll 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 are build with Visual Studio, you'll needs to installed MSVCRT 9.0 S P1 To resolve the dependency issue.
    • For Version 1.5, the bundled OpenCV pre1.1 binary are build with Visual Studio 2005, you'll needs to installed MSVCRT 8.0 SP1 To resolve the dependency issue.
copied the OpenCV DLLs to the execution directory?
  • Make sure the unmanaged DLLs is 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 being altered when deploying with the application.
    • For EMGU CV version 2.4 is thecudart64_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>XXXOpenCV 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.dllwhere is theXXXOpenCV 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.dllwhere is theXXXOpenCV version number.
    • The best of the 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"
is 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, 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 your project, find the difference in configuration and fix it.



If "Hello World" get the same "the type initializer for ' Emgu.CV.CvInvoke ' threw a exception." Message, try to find out t He innerexception and report it to the discussion forum



The type initializer for "Emgu.CV.CvInvoke" throws an exception workaround


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.