c# - 尝试使用 wpf 连接到扫描仪时出现错误代码

标签 c# wia

我正在使用 WIA 连接到扫描仪。我枚举设备信息,然后尝试连接到设备。我不断收到异常。

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();

我不明白为什么会这样。任何帮助将不胜感激。

最佳答案

HRESULT:0x80210006WIA_ERROR_BUSY

来自WIA API Error Codes page :

WIA_ERROR_BUSY        The WIA device is busy.

根据 Communicating with a WIA Device in Multiple Threads or Applications ,看起来其他东西可能正在访问该设备:

If a thread currently has a device locked (it is actively communicating with that device) and another thread attempts to call a method that actively communicates with the device, the method returns a WIA_ERROR_BUSY error.

关于c# - 尝试使用 wpf 连接到扫描仪时出现错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15772373/

相关文章:

java - JAVA 的 TWAIN/WIA 实现

c# - 获取 WIA 扫描仪功能

c# - DateTimeOffset 如何处理夏令时?

c# - C# 中的预处理器指令

c# - 如何在使用 NAudio 播放 mp3 时获取当前时间?

c++ - 如何在 C++ 中使用 WIA?

c# - 使用c#从另一个进程调用一个函数

c# - ASP.NET GridView 将两个字段绑定(bind)到一列

iis - Safari 访问受 Windows 集成身份验证(又名 NTLM)保护的网站时出现问题

c# - WIA 扫描仪,无法获取/设置 4104 和 6146 属性(颜色、颜色深度)