Wia 2.0 duplex scanning throw exception "System.outofmemoryException" C#

622 Views Asked by At

I'm using WIA on C#. When I set the properties "pages" to 1 and "docuemnt handling select" to 5 (to enable AFD and Duplex scaning), I get an exception at the method "wiaCommonDialog.ShowTransfer".

The exception is "System.OutOfMemoryExcepion".

Can you help me to fix it? Do I use the right values?

try
{
     SetWIAProperty(device.Properties, "3096", 1);//pages to 1
     SetWIAProperty(device.Properties,"3088",5);//Handling select to 5
     if (init == false)
     {
          init = true;
     }
     wiaCommonDialog = new WIA.CommonDialog();
     while (true)
     {
          object imgFile = (ImageFile)wiaCommonDialog.ShowTransfer(item,WIA.FormatID.wiaFormatJPEG,false);//Here the exception is shown
          object imgFile2=(ImageFile)wiaCommonDialog.ShowTransfer(item, WIA.FormatID.wiaFormatJPEG, false);
          if (imgFile != null)
          {
               imagenes.Add((ImageFile)imgFile);
               leyo = true;
          }
          if (imgFile2 != null)
          {
               imagenes.Add((ImageFile)imgFile2);
               leyo = true;
          }
     }
}
0

There are 0 best solutions below