WIA收到错误HRESULT E_FAIL已从调用COM组件返回

时间:2015-11-16 11:13:15

标签: c# wpf visual-studio-2012 windows-8 wia

选择扫描仪设备进行文档扫描后出现错误: 这是我的代码:



public ImageFile Scan()
        {
            ImageFile image;
            try
            {
                CommonDialog dialog = new CommonDialog();
                image = dialog.ShowAcquireImage(
                        WiaDeviceType.ScannerDeviceType,
                        WiaImageIntent.ColorIntent,
                        WiaImageBias.MaximizeQuality,
                        WIA.FormatID.wiaFormatJPEG,
                        false,
                        true,
                        false);
                return image;
            }
            catch (COMException ex)
            {
                if (ex.ErrorCode == -2145320939)
                {
                    throw new ScannerNotFoundException();
                }
                else
                {
                    throw new ScannerException("COM Exception", ex);
                }
            }
        }




操作系统:Windows 8 Pro 64位 IDE:VIsual Studio 2012 语言:C# 技术:WPF 图书馆:Interop.WIA 2.0

在wpf项目中,我选择Any CPU Platform目标。 有时得到"检索COM类工厂失败"出现设备选择对话框之前出错。

- 这支持WIA 2.0 32和64bit任何操作系统。 - 这支持使用WIA 2.0进行双面扫描

有时它的工作正常,有时会出错。那么我需要做什么?

0 个答案:

没有答案