c# - 错误 'Emgu.CV.CvInvoke' 的类型初始值设定项引发了 C#、Opencv 和 EmguCv 的异常

标签 c#

我已经使用 EmguCV 在 C# 中编写了一个简单的程序来面对检测到的 VS 2010,但我收到以下异常:

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

我正在尝试修复此链接:http://www.emgu.com/wiki/index.php/Download_And_Installation#The_type_initializer_for_.27Emgu.CV.CvInvoke.27_threw_an_exception

我复制了所有的dll,但仍然出错。

我使用 window 7 pro x86、VS 2010、EmguCV2.4.2 并遵循本教程:http://www.youtube.com/watch?v=vdjoutNR2DQ

帮帮我!

最佳答案

@Marc Gravell:这是我的问题

    See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'opencv_core242': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Emgu.CV.CvInvoke.cvRedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.cvCreateCameraCapture(Int32 index)
at Emgu.CV.Capture..ctor(Int32 camIndex)
at Emgu.CV.Capture..ctor()
at WindowsFormsApplication2.Form1.Form1_Load(Object sender, EventArgs e) in D:\khtn\new\do an\project\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:line 45
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///G:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
WindowsFormsApplication2
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/khtn/new/do%20an/project/WindowsFormsApplication2/WindowsFormsApplication2/bin/Debug/WindowsFormsApplication2.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///G:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///G:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///G:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
Emgu.CV
Assembly Version: 2.4.2.1777
Win32 Version: 2.4.2.1777
CodeBase: file:///D:/khtn/new/do%20an/project/WindowsFormsApplication2/WindowsFormsApplication2/bin/Debug/Emgu.CV.DLL
----------------------------------------
Emgu.Util
Assembly Version: 2.4.2.1777
Win32 Version: 2.4.2.1777
CodeBase: file:///D:/khtn/new/do%20an/project/WindowsFormsApplication2/WindowsFormsApplication2/bin/Debug/Emgu.Util.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///G:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///G:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Emgu.CV.UI
Assembly Version: 2.4.2.1777
Win32 Version: 2.4.2.1777
CodeBase: file:///D:/khtn/new/do%20an/project/WindowsFormsApplication2/WindowsFormsApplication2/bin/Debug/Emgu.CV.UI.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

    <configuration>
    <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

关于c# - 错误 'Emgu.CV.CvInvoke' 的类型初始值设定项引发了 C#、Opencv 和 EmguCv 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16416036/

相关文章:

c# - 我的 Mapper 类应该注入(inject)我的 Controller 还是直接实例化它?

c# - javascript 和 C# 中的 SHA1 base64 算法

c# - 如何检测此字典键是否存在于 C# 中?

C# 高级形式 "please wait"

c# - 将十六进制枚举参数从 C# 传递到 C

c# - asp.net mvc文件下载--System.FormatException : An invalid character was found in the mail header

c# - SDL Tridion 事件订阅取消订阅问题

c# - 如何通过套接字发送对象 C#

c# - WPF 数据绑定(bind)到带有枚举键的字典

c# - 使用 Update.Push 时,mongodb C# 驱动程序未在嵌入式对象列表中生成新添加文档的 ObjectId