使用C#应用程序通过网络摄像头捕获图像时引发异常 [英] exception throwen when capture image by web cam using c# app

查看:104
本文介绍了使用C#应用程序通过网络摄像头捕获图像时引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我试图通过网络摄像头获取图像.我已将相关的.dll添加到参考中.项目可以构建而没有任何错误.运行该异常时,将引发该异常.

"{"无法加载文件或程序集"AForge.Video,版本= 2.2.3.0,区域性=中性,PublicKeyToken = cbfb6e07d173c401"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040):" AForge.Video,版本= 2.2.3.0,区域性=中性,PublicKeyToken = cbfb6e07d173c401}"


执行此方法时会发生

SetCamera(0);

无法进入setCamara方法. camara已经是PC的插件

//SetCamara的内容

Hi All,

I''ve trying to get image via web cam. I have added related .dll into reference. Project can build without any bugs. When it run this exception is thrown.

"{"Could not load file or assembly ''AForge.Video, Version=2.2.3.0, Culture=neutral, PublicKeyToken=cbfb6e07d173c401'' or one of its dependencies. The located assembly''s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"AForge.Video, Version=2.2.3.0, Culture=neutral, PublicKeyToken=cbfb6e07d173c401"}"


It will happen when execute this method

SetCamera(0);

cannot move into setCamara method. camara is already plugin to the PC

// content of SetCamara

public void SetCamera(int index)        
        {
            if (Devices.Count < 1)
            {
                //throw new IndexOutOfRangeException("There is no device with index " + index);
                throw new IndexOutOfRangeException("There is no device with index " );
            }

            //SelectedDevice = new VideoCaptureDevice(Devices[index].MonikerString);
            SelectedDevice = new VideoCaptureDevice(Devices[0].MonikerString);
        }



如果有人有解决此问题的想法,请告诉我.

谢谢,
Chamara



If anyone have idea to resolve this problem, pls let me know.

Thanks,
Chamara

推荐答案

请参阅我对问题的评论并检查情况.但我希望有一个不错的解决方法. AForge.NET是开源的.将其以源项目的形式添加到您的解决方案中,将其作为项目引用(添加引用"窗口的项目"选项卡),并构建整个解决方案.在每个版本中,将自动支持引用的装配体与实际装配体之间的对应关系.这是拥有源代码的真正美丽……

此处:
http://en.wikipedia.org/wiki/AForge.NET [ http://www.aforgenet.com/ [ ^ ],
http://www.aforgenet.com/framework/downloads.html [ http://aforge.googlecode.com/files/AForge.NET %20Framework-2.2.4.zip [ ^ ].

—SA
Please see my comment to the question and check up things. But I would prefer a nice workaround. AForge.NET is open source. Add it in the form of the source project to your solution, reference it as project ("Projects" tab of the "Add Reference" window) and build the whole solution. The correspondence between referenced and actual assembly will be supported automatically in each build. This is the real beаuty of having source code…

Here:
http://en.wikipedia.org/wiki/AForge.NET[^],
http://www.aforgenet.com/[^],
http://www.aforgenet.com/framework/downloads.html[^].

Source code is here: http://aforge.googlecode.com/files/AForge.NET%20Framework-2.2.4.zip[^].

—SA


感谢,

我发现了错误.版本2.2.4.0的Aforge.video.dll

但是项目需要的版本是2.2.3.0.因此,我已经替换了正确的dll.然后它运行时没有错误.
Thanks,

I found the error. Aforge.video.dll of version 2.2.4.0

But project needed version 2.2.3.0 .so I have replase correct dll.then it run without bugs.


这篇关于使用C#应用程序通过网络摄像头捕获图像时引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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