Click here to Skip to main content
14,391,880 members
   

C#

 
Question.NET Standard 2.1, Xamarin Android/iOS & Emit Pin
Super Lloyd19-Nov-19 14:00
MemberSuper Lloyd19-Nov-19 14:00 
AnswerRe: .NET Standard 2.1, Xamarin Android/iOS & Emit Pin
Super Lloyd20-Nov-19 1:45
MemberSuper Lloyd20-Nov-19 1:45 
QuestionNew Object Pool Library Pin
Justin-A-Miller19-Nov-19 9:59
MemberJustin-A-Miller19-Nov-19 9:59 
AnswerRe: New Object Pool Library Pin
OriginalGriff19-Nov-19 10:12
mveOriginalGriff19-Nov-19 10:12 
GeneralRe: New Object Pool Library Pin
Justin-A-Miller19-Nov-19 10:22
MemberJustin-A-Miller19-Nov-19 10:22 
GeneralRe: New Object Pool Library Pin
OriginalGriff19-Nov-19 10:51
mveOriginalGriff19-Nov-19 10:51 
GeneralRe: New Object Pool Library Pin
Justin-A-Miller20-Nov-19 4:48
MemberJustin-A-Miller20-Nov-19 4:48 
QuestionHow to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 2:36
MemberMember 1094325619-Nov-19 2: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 2:50
mveRichard MacCutchan19-Nov-19 2:50 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 2:59
MemberMember 1094325619-Nov-19 2:59 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 3:19
mveRichard MacCutchan19-Nov-19 3:19 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 3:27
MemberMember 1094325619-Nov-19 3:27 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 3:32
mveRichard MacCutchan19-Nov-19 3:32 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 4:31
MemberMember 1094325619-Nov-19 4:31 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 4:40
mveRichard MacCutchan19-Nov-19 4:40 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 4:52
MemberMember 1094325619-Nov-19 4:52 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 5:02
mveRichard MacCutchan19-Nov-19 5:02 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 5:08
MemberMember 1094325619-Nov-19 5:08 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 5:13
mveRichard MacCutchan19-Nov-19 5:13 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 5:30
MemberMember 1094325619-Nov-19 5:30 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 5:45
mveRichard MacCutchan19-Nov-19 5:45 
AnswerRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 3:02
communityengineerPete O'Hanlon19-Nov-19 3:02 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 3:23
MemberMember 1094325619-Nov-19 3:23 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 3:37
communityengineerPete O'Hanlon19-Nov-19 3:37 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 3:38
communityengineerPete O'Hanlon19-Nov-19 3: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.