Search code examples
c#windows-phone-7windows-phone-8windows-phone-8.1windows-phone-7.1

AppointmentManager.RequestStoreAsync throws system.unauthorizedaccessexception in Windows Phone


I am trying to access the appointments from the Windows Phone calendar

public async Task <AppointmentStore> getAppointments()
    {

        AppointmentStore appointmentStore = await  AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);
        return appointmentStore;

    }

I have already the "enabled" the "Appointments" in the Capabilities tab of PackageManifest file. In the other solutions on the stack overflow it was suggested to enable the required permission which I did. I have also ran the Visual Studio as an administrator. However, the system continues to throws the same unauthorized access exception.


Solution

  • When using AppointmentStoreAccessType.AppCalendarsReadWrite no exceptions are thrown.

    Using AppointmentStoreAccessType.AllCalendarsReadOnly throws unauthorized exception. Which is not harmful, doesn't make the app crash. This just means you don't have ChangeTracker property.

    You can still use the appointmentStore object and get list of appointments and other things. Check screenshot.enter image description here

    I hope you can proceed on your project now?