UnauthorizedAccessException or unhandled Exception when accessing Geolocator in Windows Phone

When using the Geolocator GetGeopositionAsync () method, it is necessary to handle the necessary exceptions that may arise based on various scenarios. One such scenario is the Location is disabled by the use in the Phone Settings.

UnauthorizedAccessException or unhandled Exception when accessing Geolocator in Windows Phone

In this case, when the Geolocator’s GetGeopositionAsync() method is called, you will receive the UnauthorizedAccessException or unhandled Exception as shown below.

UnauthorizedAccessException or unhandled Exception when accessing Geolocator in Windows Phone

“An exception of type ‘System.Exception’ occurred in mscorlib.ni.dll but was not handled in user code

WinRT information: Your App does not have permission to access location data. Make sure you have defined ID_CAP_LOCATION in the application manifest and that on your phone, you have turned on location by checking Settings > Location.

If there is a handler for this exception, the program may be safely continued.”

Leave Your Comment

Liked this content?. Please spread the word :)