COMException: 'Error HRESULT E_FAIL after updating to Windows 10 build 17134

0

In my Xamarin.Forms project (currently supporting only UWP) we have a platform specific code that claims a Barcode scanner. This logic was working fine when the solution was run on my "LocalMachine" on Windows 10 build 16299. After updating to Windows 10 build 17134 every time it crashes with the following exception:

System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'
Error code (0x80004005)

That exception is raised from the await EnableScanner() line bellow:

 private async void Initialize(object sender, RoutedEventArgs e)
    {
        // create the barcode scanner. 
        if (await CreateDefaultScannerObject())
        {
            // after successful creation, claim the scanner for exclusive use and enable it so that data reveived events are received.
            if (await ClaimScanner())
            {
                claimedScanner.ReleaseDeviceRequested += claimedScanner_ReleaseDeviceRequested;

                // after successfully claiming, attach the datareceived event handler.
                claimedScanner.DataReceived += claimedScanner_DataReceived;
                UpdateOutput(ScanningLang.DataReceivedAttached);

                claimedScanner.IsDecodeDataEnabled = true;

                if (await EnableScanner())
                    UpdateOutput(ScanningLang.ScanReady);
            }
        }
        else
        {
            UpdateOutput(ScanningLang.NoBarcodeScanner);
        }
    }

EnableScanner method:

 private async Task<bool> EnableScanner()
    {
        if (claimedScanner == null)
            return false;

        await claimedScanner.EnableAsync();
        UpdateOutput(ScanningLang.EnabledBarcodeSuccess);

        return true;
    }
c#
.net
uwp
asked on Stack Overflow May 2, 2018 by Georgi Koemdzhiev • edited Jul 2, 2018 by halfer

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0