Hello,
i have a question on my mind.
Iam developing application which uses twain layer to scan images. So far everything worked fine, but today while testing i got Attempted to read or write protected memory error.
Basicly what i do:
- set capabilities via imported dll calls of twain.dll
- call acquire call via imported dll calls of twain.dll
i get back IntPtr on the data from scanner, which i convert to bitmap by creating empty bitmap and filling bitmap with pixel data. Then i flip newly created bitmap.
At last mentioned i get sometimes error "Attempted to read or write protected memory".
Strange is that its not always, sometimes i takes 200 pages sometimes 400 pages to scan. For test purposes i used 50 papers, and for other test 1 page picture in kodak twain simulator. So its obvious that the problem is not caused by picture data. I forgot to say that i did scan 40 - 50 pages at batch a than repeated the batch.
What i dont understand is why is it happening, since memory of the picture is allocated by twain driver and not me. (EDIT: That is true, but bitmap iam creating from the twain data is created by me..)
Is it possible that the data are somehow locked by unmanaged memory manager??
Or its more likely that there is leaking memory and so all the unmanaged memory is somehow corupted?
I started with NETMasters code here: http://www.codeproject.com/kb/dotnet/twaindotnet.aspx. Dll calls where used without changes.
Any suggestions will be appreciated.