在Surface Pro 3中,如果VideoDevicesComboBox.SelectedItem =“Microsoft LifeCam Rear”,则程序崩溃。为什么? ? ? [英] In Surface Pro 3,if VideoDevicesComboBox.SelectedItem = "Microsoft LifeCam Rear",The program breakdown.why ? ? ?

查看:189
本文介绍了在Surface Pro 3中,如果VideoDevicesComboBox.SelectedItem =“Microsoft LifeCam Rear”,则程序崩溃。为什么? ? ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 WebcamCtrl.StartCapture(); 
foreach (EncoderDevice device in _vidDevices.Where(device = > device.Name == Microsoft LifeCam Rear))
{
VideoDevicesComboBox.SelectedItem = device;
break ;
}

解决方案

试试这个

  var  devices = _vidDevices.Where(device = >  device.Name ==   Microsoft LifeCam Rear); 
if (devices!= null
{
foreach (EncoderDevice device in devices)
{
VideoDevicesComboBox.SelectedItem = device;
break ;
}
}





然后分析变量 devices contains。

要使foreach循环起作用,变量 devices 应该是一个列表,即使它是空的(长度= 0)


WebcamCtrl.StartCapture();
foreach (EncoderDevice device in _vidDevices.Where(device => device.Name == "Microsoft LifeCam Rear"))
{
    VideoDevicesComboBox.SelectedItem = device;
    break;
}

解决方案

Try this

var devices = _vidDevices.Where(device => device.Name == "Microsoft LifeCam Rear");
if (devices != null)
{
    foreach (EncoderDevice device in devices)
    {
        VideoDevicesComboBox.SelectedItem = device;
        break;
    }
}



Then analyze what the variable devices contains.
For a foreach loop to work, the variable devices should be a list, even if it is empty (length = 0).


这篇关于在Surface Pro 3中,如果VideoDevicesComboBox.SelectedItem =“Microsoft LifeCam Rear”,则程序崩溃。为什么? ? ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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