How to fix error "The remote procedure call failed" in C# - connecting to scanner

1

I’m trying to scan a paper with scanner and store it. I’m using C# , WIA , Kodak scaner i1310.

I get The remote procedure call failed(0x800706be) error when this line executes : var imageFile = (ImageFile)scannerItem.Transfer(FormatID.wiaFormatJPEG);

and here is my code :

private void btnScan1_Click(object sender, EventArgs e)
{


    var deviceManager = new DeviceManager();

    DeviceInfo firstScannerAvailable = null;

    for (int i = 1; i <= deviceManager.DeviceInfos.Count; i++)
    {

        if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType)
        {
            continue;
        }

        firstScannerAvailable = deviceManager.DeviceInfos[i];

        break;
    }


    var device = firstScannerAvailable.Connect();


    var scannerItem = device.Items[1];

    var   imageFile = (ImageFile)scannerItem.Transfer(FormatID.wiaFormatJPEG);

    var path = @"C:\Documents\scan.png";

    if (File.Exists(path))
    {
        File.Delete(path);
    }
    imageFile.SaveFile(path);
}

can any body help me?

c#
scanning
asked on Stack Overflow Jun 11, 2019 by Mohammad Ghaedi • edited Jun 11, 2019 by Rick Smith

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0