locked
Getting ID of scanned card via Windows.Device.SmartCards (WinRTError: The system cannot find the file specified)

    Question

  • Just to try to clear the question up, it amazes me that this does not work (as per http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.smartcards.smartcardprovisioning.getidasync.aspx)

    smartCardProvisioning.getIdAsync() seems to be broken, and I cannot find an example anywhere that this in fact works.

    I'm trying to get the unique ID of the scanned SmartCard via the code below.  Everything works up until:

    return provisioning.getIdAsync().then(function (cardId) { // provisioning.getNameAsync() works fine
        console.log({
         title: provisioning.smartCard.reader.name,
         text: cardId
        });
      }, function (err) {
        console.log(err); //WinRTError: The system cannot find the file specified at getResultsOfAsyncOp 
    });

    I'm getting the error `WinRTError: The system cannot find the file specified at getResultsOfAsyncOp Function code:338:5)`

    var selector = Windows.Devices.SmartCards.SmartCardReader.getDeviceSelector();
    Windows.Devices.Enumeration.DeviceInformation.findAllAsync(selector, null).then(
        function (devices) {
            return WinJS.Promise.join(devices.map(function (device) {
                return Windows.Devices.SmartCards.SmartCardReader.fromIdAsync(device.id)
            }));
        }).then(function (readers) {
            return WinJS.Promise.join(readers.map(function (reader) {
                return reader.findAllCardsAsync();
            }));
        }).then(function (cardEnumerationList) {
            var provisioningPromises = [];
            for (var cardListIndex = 0;
                cardListIndex < cardEnumerationList.length;
                ++cardListIndex) {
    
                var cardList = cardEnumerationList[cardListIndex];
    
                for (var cardIndex = 0;
                        cardIndex < cardList.length;
                        ++cardIndex) {
    
                    provisioningPromises.push(
                        Windows.Devices.SmartCards.SmartCardProvisioning
                        .fromSmartCardAsync(cardList[cardIndex]));
                }
            }
            return WinJS.Promise.join(provisioningPromises);
        }).then(function (provisioningList) {
            return WinJS.Promise.join(provisioningList.map(function (provisioning) {
                return provisioning.getIdAsync().then(function (cardName) {
                    console.log({
                    title: provisioning.smartCard.reader.name,
                    text: cardName
                    });
                }, function (err) {
                    console.log(err); // WinRTError: The system cannot find the file specified at getResultsOfAsyncOp 
                });
        }));
    });






    • Edited by tc2123 Thursday, December 18, 2014 4:43 PM
    Wednesday, November 12, 2014 7:26 PM

All replies

  • Hi tc2123,

    I don't know what getResultsOfAsyncOp is, looks like a system method.

    However I found something interesting: https://social.msdn.microsoft.com/Forums/en-us/d650d547-c054-497d-82b0-3ed6fbe9af28/storagefoldergetfileasync-throws-exception-when-file-doesnt-exist-in-win8-rp?forum=winappswithhtml5, who has the same question as you.

    Looks like you may have setting something in Visual Studio to ensure it catch the correct exception from promise pattern. You probably will satisfied with answer from https://social.msdn.microsoft.com/Forums/windowsapps/en-US/96055739-7e6b-4df4-859a-3b8244327598/why-fail-in-promise-does-not-catch-errors?forum=winappswithhtml5#26a9e36b-23f4-4e0b-9709-3c03eea574cf

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, November 13, 2014 2:42 AM
    Moderator
  • Thanks, I did come across this question while I was working through the problem, and though that solves the issue of Visual Studio breaking on the error, it doesn't solve the issue of why the error persists; now, the exception is just thrown a little less obtrusively.

    I'm wondering if getIdAsync() is broken.

    Thursday, November 13, 2014 2:01 PM
  • Here we may need set breakpoint in getIdAsycn() method to see how it works, and as a suggestion, you will not like to see too much WinJS.Promise while trying to debug the codes.

    I guess getResultsOfAsyncOp should be a internal API that used by WinJS. Looks like step by step debug can help you find which file is required or specified in  getResultsOfAsyncOp method.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Wednesday, November 26, 2014 9:03 AM
    Moderator