类型初始化异常 [英] Type initialization exception

查看:252
本文介绍了类型初始化异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了imageHolder的类:

I created imageHolder class:

 public class ImageHolder : Image<Bgr, Byte>
    {   
        private String imagePath;

        public ImageHolder(String path):base(path)
        {
           this.imagePath = path;                     
        }   
        public String imgPathProperty
        {
            get
            { return imagePath; }
            set
            { imagePath = value; }
        }
    }

我创建类的实例,并初始化它,像这样:

I create instance of the class and initialize it,like this:

  private ImageHolder originalImageHolder;
  originalImageHolder = new ImageHolder(openFileDialog.FileName);

在运行时我得到这个异​​常:

In runtime i get this exception:

的类型初始Emgu.CV.CvInvoke'引发了异常。

下面是解决方案资源管理器窗口:

Here is Solution Explorer window:

任何想法,为什么我得到这个例外,我该如何解决?

Any idea why i get this exception and how can i fix it?

感谢你在前进。

推荐答案

的<一个href="http://msdn.microsoft.com/en-us/library/system.typeinitializationexception.aspx">TypeInitializationException (您看到的除外)被抛出时静态构造函数抛出一个异常,或当你试图访问一个类,其中静态​​构造函数抛出了一个异常 - 它的<一个href="http://msdn.microsoft.com/en-us/library/system.exception.innerexception.aspx">InnerException属性是包含已actualy抛出的异常的细节性 - 这就是你需要调查的异常

The TypeInitializationException (the exception that you are seeing) is thrown whenever a static constructor throws an exception, or whenever you attempt to access a class where the static constructor threw an exception - its InnerException property is the property that contains the detail of the exception that was actualy thrown - this is the exception that you need to investigate.

在您的屏幕截图这种情况下,这个问题似乎是,该DLLopencv_core240.dll无法被发现。这可能是由于多种原因

In this case from your screenshot the problem appears to be that the DLL "opencv_core240.dll" could not be found. This could be for a number of reasons

  • 在该DLL找不到
  • 在其中一个DLL的依赖找不到
  • 在该DLL是不正确的图像格式(32位而不是64位)

我建议你看一看这个问题以查看是否有任何的建议,在那里帮助你。

I'd suggest that you take a look at this question to see if any of the suggestions on there help you.

这篇关于类型初始化异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆