0
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using WebcamControl;
    using System.Drawing.Imaging;
    using Microsoft.Expression.Encoder;
    using System.Reflection;

    namespace SMS
    {
    /// <summary>
    /// Interaction logic for camphoto.xaml
    /// </summary>
    public partial class camphoto : Window
    {
        public camphoto()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
            Binding bndg_1 = new Binding("SelectedValue");
            bndg_1.Source = comboBox1;
            webcam1.SetBinding(WebcamControl.Webcam.VideoDeviceProperty, bndg_1);

            //set properties
            webcam1.PictureFormat = ImageFormat.Jpeg;

            webcam1.FrameRate = 30;
            webcam1.FrameSize = new System.Drawing.Size(320, 240);

            comboBox1.SelectedIndex = 0;
            string str = Microsoft.Expression.Encoder.Devices.EncoderDeviceType.Video.ToString();

                FindDevice();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void FindDevice()
        {
            var vidDevice = Microsoft.Expression.Encoder.Devices.EncoderDevices.FindDevices(Microsoft.Expression.Encoder.Devices.EncoderDeviceType.Video);
            foreach (var data in vidDevice)
            {
                comboBox1.Items.Add(data.Name);
            }
        }
    }
}

嗨朋友,这是我的代码,它是网络摄像头的预览。但是当我调试它时会出现一个错误。

“找不到文件异常:无法加载文件或程序集'Microsoft.Expression.Encoder,Version = 4.0.0.0,Culture = Neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。系统找不到指定的文件。”

我已经添加了Microsoft.Expression.Encoder对项目参考的参考。但我不明白它为什么会来。请帮我。

4

2 回答 2

1

转到项目属性->构建部分并将平台目标更改为x86

于 2014-06-07T07:05:16.287 回答
0

您是否检查过您的项目配置文件不是".Net Framework 4.0 Client Profile"。如果是,请更改为".Net Framework 4.0".

还要确保引用部分具有 dll 引用。尝试清理解决方案,然后重建并交叉验证bin目录中的 dll 一次。

于 2013-05-26T12:23:34.583 回答