C# WIA Image Scanning fails with HRESULT: 0x80070050

前端 未结 2 1339
礼貌的吻别
礼貌的吻别 2021-01-21 13:17

I\'m hoping someone has come across this - I\'m trying to capture images from a document scanner using WIA, however on random machines when attempting to transfer the image resu

相关标签:
2条回答
  • 2021-01-21 14:09

    Solved.

    It turns out that WIA actually stores captured images as temporary files in the Users profile temp folder, so:

    Path.GetTempPath()
    

    or C:\Users\USER_PROFILE\AppData\Local\Temp\

    Files are stored in the format imgXXXX.tmp

    In our case - the reason this caused an issue, which doesn't seem to be documented anywhere on the net, is that we polled the scanner every few seconds - creating a temp file, as there are only 4x's, there can be a max of 65K temp files before WIA will bug out.

    Setting up a routine to clear out old image files from this temp folder immediately resolved the issue.

    0 讨论(0)
  • 2021-01-21 14:13

    I came across this same problem when trying to use WIA to read images off of a camera device. The proper solution is to dispose of the WIA.ImageFile properly. This cleans up the tmp file.

    Marshal.ReleaseComObject(Image1);
    

    I found this on CodePrjoct, link

    0 讨论(0)
提交回复
热议问题