【问题标题】:Virtual Smart Card creation - 'Element not found. (Exception from HRESULT: 0x80070490)'创建虚拟智能卡 - '未找到元素。 (来自 HRESULT 的异常:0x80070490)'
【发布时间】:2019-06-28 05:51:12
【问题描述】:

我遇到了有关创建虚拟智能卡的问题。 RequestVirtualSmartCardCreationAsync() 抛出一个奇怪的异常。我附上了sn-p的代码。

public async void ScenarioCreateTpmVirtualSmartCard()
    {
        IBuffer adminKey = CryptographicBuffer.CreateFromByteArray(
        new byte[] {
             0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
             0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
             0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
        });
        SmartCardPinPolicy pinPolicy = new SmartCardPinPolicy()
        {
            MinLength = 8,
            MaxLength = 127,
            LowercaseLetters = SmartCardPinCharacterPolicyOption.Allow,
            UppercaseLetters = SmartCardPinCharacterPolicyOption.Allow,
            Digits = SmartCardPinCharacterPolicyOption.Allow,
            SpecialCharacters = SmartCardPinCharacterPolicyOption.Allow
        };
        SmartCardProvisioning cardProvisioning = await SmartCardProvisioning.RequestVirtualSmartCardCreationAsync(
        "Contoso Virtual Smart Card", adminKey, pinPolicy, Guid.NewGuid());
        if (cardProvisioning == null)
            return;
    }

问题是当我运行这个方法时,我得到 System.Exception 说

未找到元素。 (HResult 异常:0x80070490)

我正在使用 VS 2017,并在 Windows 10 上运行此示例。任何帮助将不胜感激...

【问题讨论】:

    标签: c# smartcard tpm


    【解决方案1】:

    在主 UI 线程上未调用 RequestVirtualSmartCardCreationAsync 时出现此问题。确保您对RequestVirtualSmartCardCreationAsync 的调用是通过在页面上单击按钮级别完成的,或者使用BeginInvokeOnMainThreadInvokeOnMainThreadAsync 的各种形式之一。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-29
      • 2016-08-23
      相关资源
      最近更新 更多