I am trying to use the ContactManager class in the Windows 10 Generic Application API. I am trying to do this on a Windows 10 Desktop computer.
I get a "System.UnauthorizedAccessException" exception when trying to request a contact list using ContactManager.RequestStoreAsync ().
In previous versions, this feature only worked on Windows Phone devices. The Microsoft documentation just says that it now requires the Windows 10 device family, but I'm out of 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;
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;
}
source
share