尝试使用wpf连接到扫描仪时的错误代码

本文关键字:扫描仪 错误代码 连接 wpf | 更新日期: 2023-09-27 18:07:18

我正在使用WIA连接到扫描仪。我列举设备信息,然后尝试连接到设备。我总是得到这个异常。

异常from HRESULT: 0x80210006

我在WPF窗口后面的代码中调用代码。

        DeviceManager manager = new DeviceManagerClass();
        DeviceInfo device = null;
        foreach (DeviceInfo deviceInfo  in manager.DeviceInfos)
        {
            var ID = deviceInfo.DeviceID;
            var props = deviceInfo.Properties ;
            foreach (Property property in props)
            {
                var name = property.Name;
                var descr = property.get_Value() as string;
            }
            var type = deviceInfo.Type;
            if (type == WiaDeviceType.ScannerDeviceType)
                device = deviceInfo;
        }
        if (device != null)
              device.Connect();
我不明白为什么会发生这种事。

尝试使用wpf连接到扫描仪时的错误代码

HRESULT: 0x80210006WIA_ERROR_BUSY

来自WIA API错误代码页面:

WIA_ERROR_BUSY        The WIA device is busy.

根据在多线程或应用程序中与WIA设备通信,看起来可能有其他东西正在访问该设备:

如果一个线程当前有一个设备被锁定(它正在积极地与该设备通信),而另一个线程试图调用一个正在与该设备通信的方法,该方法返回一个WIA_ERROR_BUSY错误。