Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
Question.NET Standard 2.1, Xamarin Android/iOS & Emit Pin
Super Lloyd19-Nov-19 13:00
Super Lloyd19-Nov-19 13:00 
AnswerRe: .NET Standard 2.1, Xamarin Android/iOS & Emit Pin
Super Lloyd20-Nov-19 0:45
Super Lloyd20-Nov-19 0:45 
QuestionNew Object Pool Library Pin
Justin-A-Miller19-Nov-19 8:59
Justin-A-Miller19-Nov-19 8:59 
AnswerRe: New Object Pool Library Pin
OriginalGriff19-Nov-19 9:12
mveOriginalGriff19-Nov-19 9:12 
GeneralRe: New Object Pool Library Pin
Justin-A-Miller19-Nov-19 9:22
Justin-A-Miller19-Nov-19 9:22 
GeneralRe: New Object Pool Library Pin
OriginalGriff19-Nov-19 9:51
mveOriginalGriff19-Nov-19 9:51 
GeneralRe: New Object Pool Library Pin
Justin-A-Miller20-Nov-19 3:48
Justin-A-Miller20-Nov-19 3:48 
QuestionHow to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 1:36
Member 1094325619-Nov-19 1:36 
I have the code below for scanning all papers. It works but the problem is when all papers will finish, it shows the error:

Exception User-Unhandeled System.runtime.InterpService.COMEException: Exception From HRESULT:0*80210003

which belongs to this line:
var imgFile = (ImageFile)ScanerItem.Transfer();
Does anyone know how to fix it?
Thanks


How can i fix it? Here is the code:


bool continueScanning2 = true;
    try
    {
        await Task.Run(() =>
        {
            var deviceManager = new DeviceManager();
            DeviceInfo AvailableScanner = null;
            while (continueScanning2)
            {
                for (int i = 1; i <= deviceManager.DeviceInfos.Count; i++)
                {
                    if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType) // Skip device If it is not a scanner
                    {
                        continue;
                    }
                    AvailableScanner = deviceManager.DeviceInfos[i];
                    break;
                }
                var device = AvailableScanner.Connect();
                var ScanerItem = device.Items[1];
                var imgFile = (ImageFile)ScanerItem.Transfer();
                var data = (byte[])imgFile.FileData.get_BinaryData();
                var bitmap = GetBitmapFromRawData(imgFile.Width, imgFile.Height, data);
                string name2 = Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
                var Path = @"C:\Users\...\Desktop\test\" + name2; // save the image in some path with filename.
                pictureBox1.ImageLocation = Path;
                bitmap.Save(Path, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        });
    }
    catch (COMException ex)
    {
        MessageBox.Show(ex.Message);
    }

AnswerRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 1:50
mveRichard MacCutchan19-Nov-19 1:50 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 1:59
Member 1094325619-Nov-19 1:59 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 2:19
mveRichard MacCutchan19-Nov-19 2:19 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 2:27
Member 1094325619-Nov-19 2:27 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 2:32
mveRichard MacCutchan19-Nov-19 2:32 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 3:31
Member 1094325619-Nov-19 3:31 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 3:40
mveRichard MacCutchan19-Nov-19 3:40 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 3:52
Member 1094325619-Nov-19 3:52 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 4:02
mveRichard MacCutchan19-Nov-19 4:02 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 4:08
Member 1094325619-Nov-19 4:08 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 4:13
mveRichard MacCutchan19-Nov-19 4:13 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 4:30
Member 1094325619-Nov-19 4:30 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 4:45
mveRichard MacCutchan19-Nov-19 4:45 
AnswerRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 2:02
mvePete O'Hanlon19-Nov-19 2:02 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 2:23
Member 1094325619-Nov-19 2:23 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 2:37
mvePete O'Hanlon19-Nov-19 2:37 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 2:38
mvePete O'Hanlon19-Nov-19 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.