Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 是什么导致WIA错误0x8021006C、0x8021006D和0x8021006E?_.net_Wia - Fatal编程技术网

.net 是什么导致WIA错误0x8021006C、0x8021006D和0x8021006E?

.net 是什么导致WIA错误0x8021006C、0x8021006D和0x8021006E?,.net,wia,.net,Wia,尝试设置WIA项目/设备属性时,我遇到以下错误: System.Runtime.InteropServices.COMException (0x8021006E): Exception from HRESULT: 0x8021006E at WIA.IProperty.get_SubTypeMin() ... 这是我的代码: public void SetIntProperty(Item item, int propid, int value) { foreach (Pro

尝试设置WIA项目/设备属性时,我遇到以下错误:

System.Runtime.InteropServices.COMException (0x8021006E): Exception from HRESULT: 0x8021006E
   at WIA.IProperty.get_SubTypeMin()
   ...
这是我的代码:

public void SetIntProperty(Item item, int propid, int value)
{
    foreach (Property prop in item.Properties)
    {
        if (prop.PropertyID == propid)
        {
            if (value < prop.SubTypeMin) {
                value = prop.SubTypeMin;
            }
            if (value > prop.SubTypeMax) {
                value = prop.SubTypeMax;
            }
            object objprop = value;
            prop.set_Value(ref objprop);
        }
    }
}
public void SetIntProperty(项项、int-propid、int-value)
{
foreach(item.Properties中的属性属性属性)
{
如果(prop.PropertyID==propid)
{
如果(值<最小值){
值=prop.min;
}
如果(值>属性最大值){
值=prop.max;
}
对象objprop=值;
属性设置值(参考objprop);
}
}
}

是什么原因导致此错误以及如何修复它?

这些错误是由于试图访问不支持它们的子类型的相关属性而导致的。您需要首先检查
prop.SubType
字段。您只能访问:

  • prop.SubType min
    prop.SubType max
    prop.SubType step
    如果
    prop.SubType==WiaSubType.RangeSubType
    (0x8021006E)
  • prop.SubType值
    if
    prop.SubType==WiaSubType.ListSubType | | prop.SubType==WiaSubType.FlagSubType
    (0x8021006D)
  • prop.SubType默认值
    if
    prop.SubType!=WiaSubType.UnspecifiedSubType
    (0x8021006C)