• <i id='bCDHO'><tr id='bCDHO'><dt id='bCDHO'><q id='bCDHO'><span id='bCDHO'><b id='bCDHO'><form id='bCDHO'><ins id='bCDHO'></ins><ul id='bCDHO'></ul><sub id='bCDHO'></sub></form><legend id='bCDHO'></legend><bdo id='bCDHO'><pre id='bCDHO'><center id='bCDHO'></center></pre></bdo></b><th id='bCDHO'></th></span></q></dt></tr></i><div id='bCDHO'><tfoot id='bCDHO'></tfoot><dl id='bCDHO'><fieldset id='bCDHO'></fieldset></dl></div>

    1. <small id='bCDHO'></small><noframes id='bCDHO'>

      • <bdo id='bCDHO'></bdo><ul id='bCDHO'></ul>
      <legend id='bCDHO'><style id='bCDHO'><dir id='bCDHO'><q id='bCDHO'></q></dir></style></legend>
      <tfoot id='bCDHO'></tfoot>

      1. ContactManager.RequestStoreAsync() 抛出 System.UnauthorizedAcc

        时间:2023-09-15

            1. <i id='mQSRV'><tr id='mQSRV'><dt id='mQSRV'><q id='mQSRV'><span id='mQSRV'><b id='mQSRV'><form id='mQSRV'><ins id='mQSRV'></ins><ul id='mQSRV'></ul><sub id='mQSRV'></sub></form><legend id='mQSRV'></legend><bdo id='mQSRV'><pre id='mQSRV'><center id='mQSRV'></center></pre></bdo></b><th id='mQSRV'></th></span></q></dt></tr></i><div id='mQSRV'><tfoot id='mQSRV'></tfoot><dl id='mQSRV'><fieldset id='mQSRV'></fieldset></dl></div>

              <legend id='mQSRV'><style id='mQSRV'><dir id='mQSRV'><q id='mQSRV'></q></dir></style></legend>
                <tfoot id='mQSRV'></tfoot>
                • <bdo id='mQSRV'></bdo><ul id='mQSRV'></ul>
                    <tbody id='mQSRV'></tbody>

                  <small id='mQSRV'></small><noframes id='mQSRV'>

                  本文介绍了ContactManager.RequestStoreAsync() 抛出 System.UnauthorizedAccessException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 Windows 10 通用应用程序 API 中使用 ContactManager 类.我正在尝试在 Windows 10 桌面计算机上执行此操作.

                  I am trying to use the ContactManager class in the Windows 10 Universal apps API. I am trying to do this on a Windows 10 Desktop machine.

                  我在尝试使用 ContactManager.RequestStoreAsync() 请求联系人列表时收到异常System.UnauthorizedAccessException".

                  I am receiving an exception, "System.UnauthorizedAccessException" when trying to request a list of contacts using ContactManager.RequestStoreAsync().

                  在以前的版本中,此功能仅适用于 Windows Phone 设备.微软文档只是说它现在需要一个 Windows 10 设备系列,但我没有任何运气.

                  In previous versions, this function only worked on Windows Phone devices. The Microsoft documentation just says it requires a Windows 10 Device family now, but I'm not having any luck.

                  using Windows.ApplicationModel.Contacts;
                  
                  public async Task<List<String>> getContacts()
                      {
                          List<String> listResults = new List<string>();
                          ContactStore store = null;
                          IReadOnlyList<ContactList> list = null;
                          ContactReader reader = null;
                          ContactBatch batch = null;
                  
                          // *** This RequestStoreAsync() call is where the exception is thrown. All the cases below have the same issue. ***
                          //store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadWrite);
                          //store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);
                          store = await ContactManager.RequestStoreAsync();
                  
                          list = await store.FindContactListsAsync();
                          foreach (ContactList contactList in list)
                          {
                              reader = contactList.GetContactReader();
                              batch = await reader.ReadBatchAsync();
                              foreach (Contact contact in batch.Contacts)
                              {
                                  listResults.Add(contact.Name);
                              }
                          }
                  
                  
                          return listResults;
                      }
                  

                  推荐答案

                  好吧,我想我自己找到了答案.看起来如果您手动将联系人"功能添加到 Package.appxmanifest 文件中,它将解决问题.

                  Alright, I think I discovered the answer on my own. Looks like if you add the "contacts" capability to the Package.appxmanifest file manually, it will fix the issue.

                  此功能没有 UI 选项.您必须以某种方式知道它存在,在文本编辑器而不是 UI 中编辑文件,然后添加:

                  There is no UI option for this capability. You have to somehow know it exists, edit the file in a text editor instead of in the UI, and add:

                  <uap:Capability Name="contacts" />
                  

                  这篇关于ContactManager.RequestStoreAsync() 抛出 System.UnauthorizedAccessException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:FromBluetoothAddressAsync 永远不会在 WPF 应用程序中的 Windows 10 Creato 下一篇:Windows Store 应用程序内购买订阅模式

                  相关文章

                  1. <legend id='CQTOs'><style id='CQTOs'><dir id='CQTOs'><q id='CQTOs'></q></dir></style></legend>

                  2. <small id='CQTOs'></small><noframes id='CQTOs'>

                      <bdo id='CQTOs'></bdo><ul id='CQTOs'></ul>

                      <tfoot id='CQTOs'></tfoot>
                    1. <i id='CQTOs'><tr id='CQTOs'><dt id='CQTOs'><q id='CQTOs'><span id='CQTOs'><b id='CQTOs'><form id='CQTOs'><ins id='CQTOs'></ins><ul id='CQTOs'></ul><sub id='CQTOs'></sub></form><legend id='CQTOs'></legend><bdo id='CQTOs'><pre id='CQTOs'><center id='CQTOs'></center></pre></bdo></b><th id='CQTOs'></th></span></q></dt></tr></i><div id='CQTOs'><tfoot id='CQTOs'></tfoot><dl id='CQTOs'><fieldset id='CQTOs'></fieldset></dl></div>