相关疑难解决方法(0)

ContactManager.RequestStoreAsync()抛出System.UnauthorizedAccessException

我试图在Windows 10 Universal apps API中使用ContactManager类.我试图在Windows 10桌面计算机上执行此操作.

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

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

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)
        { …
Run Code Online (Sandbox Code Playgroud)

c# windows windows-store-apps windows-10

2
推荐指数
1
解决办法
1010
查看次数

标签 统计

c# ×1

windows ×1

windows-10 ×1

windows-store-apps ×1