Microsoft Windows图像采集无法在Windows 10(64位)中工作 [英] Microsoft windows image acquisition not working in windows 10(64 bit)

查看:993
本文介绍了Microsoft Windows图像采集无法在Windows 10(64位)中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.Net Windows应用程序中使用Microsoft Windows Image Acquisition(WIA)dll来扫描文档(.tiff图像)



它与Windows 7一起工作正常。



但微软Windows图像采集(WIA)无法在Windows 10 64位系统上运行。



代码部分



I have use Microsoft Windows Image Acquisition (WIA) dll in .Net windows application to Scan document (.tiff images)

And It working fine with windows 7.

But Microsoft Windows Image acquisition (WIA) dll not wokring on Windows 10 64 bit system.

code part

img = (WIA.ImageFile)_scanner.Items[1].Transfer(WIA.FormatID.wiaFormatTIFF)





抛出异常

系统。 Runtime.InteropServices.COMException



附加信息:HRESULT异常:0x8021006B



请提供任何解决方案< br $>






代码: -



throws below exception
System. Runtime.InteropServices.COMException

Additional information: Exception from HRESULT: 0x8021006B

Please provide any solution



Code:-

try
{
   WIA.ICommonDialog dialog = new WIA.CommonDialog();
   WIA.Device _scanner = Utility.SelectScannerDeviceName(ScannerModel);
   if (_scanner == null)
   {
      throw new Exception("Scanner Connection Error");
   }
   if (ScannerCategory == "NORMAL")
   {
      if (GrayBlackWhiteColor == "GRAY SCALE")
      {
         _scanner.Items[1].Properties["6146"].set_Value((Object)(2)); 
      }
      else if (GrayBlackWhiteColor == "COLOR")
      {
         _scanner.Items[1].Properties["6146"].set_Value((Object)(1)); 
      }
      else if (GrayBlackWhiteColor == "BLACK & WHITE")
      {
         _scanner.Items[1].Properties["6146"].set_Value((Object)(4)); 
      }   
      _scanner.Items[1].Properties["6147"].set_Value(DPIHorizontal); 
      _scanner.Items[1].Properties["6148"].set_Value(DPIVertical); 

      _scanner.Items[1].Properties["6154"].set_Value(0); 
      _scanner.Items[1].Properties["6155"].set_Value(0);

      _scanner.Items[1].Properties[6].set_Value(DPIHorizontal);
      _scanner.Items[1].Properties[7].set_Value(DPIVertical);

      _scanner.Items[1].Properties[8].set_Value(Convert.ToInt32(8.5 * 100));
      _scanner.Items[1].Properties[9].set_Value(Convert.ToInt32(11 * 100));
   }
   else if (ScannerCategory == "ADVANCE")
   {
      if (GrayBlackWhiteColor == "GRAY SCALE")
      {
         _scanner.Items[1].Properties[17].set_Value((Object)(2)); 
      }
      else if (GrayBlackWhiteColor == "COLOR")
      {
         _scanner.Items[1].Properties[17].set_Value((Object)(1));
      }
      else if (GrayBlackWhiteColor == "BLACK & WHITE")
      {
         _scanner.Items[1].Properties[17].set_Value((Object)(4));
      }   

      _scanner.Items[1].Properties[10].set_Value(0);
      _scanner.Items[1].Properties[11].set_Value(0);   
      _scanner.Items[1].Properties[8].set_Value(Convert.ToInt32(8.5 * 100));
      _scanner.Items[1].Properties[9].set_Value(Convert.ToInt32(14 * 100));
      _scanner.Properties["Document Handling Select"].set_Value(5);
      _scanner.Items[1].Properties[6].set_Value(DPIHorizontal);
      _scanner.Items[1].Properties[7].set_Value(DPIVertical);
    
   }
   else
   {
      _scanner.Items[1].Properties[8].set_Value(Convert.ToInt32(8.5 * 100));
      _scanner.Items[1].Properties[9].set_Value(Convert.ToInt32(11 * 100));
   }

   WIA.ImageFile img;
   if (cmbScanning == 0)
   {
      img = (WIA.ImageFile)_scanner.Items[1].Transfer(WIA.FormatID.wiaFormatJPEG);
   }
   else
   {
      img = (WIA.ImageFile)_scanner.Items[1].Transfer(WIA.FormatID.wiaFormatTIFF);
   }

   sFileName = FileName + DateAndTime.Now.ToString("_dd_MMM_yyyy_HH_mm_ss") + ".TIFF";
   sFullFileName = FolderPath + "\\" + sFileName;
   if (File.Exists(sFullFileName))
   {
      File.Delete(sFullFileName);
   }

   img.SaveFile(sFullFileName);

   img = null;
}
catch (Exception ex)
{
   throw ex;
}





我的尝试:



我已经从Windows 10 64位机器添加了WIA dll引用,但仍然得到相同的错误。



What I have tried:

I have added WIA dll references from windows 10 64 bit machine but still get same error.

推荐答案

第一个解决方案:



右键点击你的项目 - >点击属性 - >点击Build - >将平台目标更改为x86。



第二解决方案:

确保WIA.dll正在64位工作。
1st Solution:

Right click on your project-> Click on properties -> Click on Build -> Change Platform target to x86.

2nd Solution:
make sure WIA.dll is working on 64 bit.


这篇关于Microsoft Windows图像采集无法在Windows 10(64位)中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆