我正在使用 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:0x80210006
是 WIA_ERROR_BUSY
。
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/