GeoLocator.GetPositionAsync giving exception when wifi is turned off

My xamarin app has a fairly simple geolocator functionality.

It looks like this:

IsBusy = true;
App.GeoLocator.DesiredAccuracy = 15;
var position = await App.GeoLocator.GetPositionAsync(10000);
EndLng = position.Longitude.ToString();
EndLat = position.Latitude.ToString();
BeginLng = position.Longitude.ToString();
BeginLat = position.Latitude.ToString();
catch(Exception e)
OnExceptionThrown(new Exception("Unable to determine location. : " + e.Message));
IsBusy = false;

This works just fine on a microsoft surface when the wifi is turned on. (I have given the app locations permission in the location privacy setting, and registered location capability in my uwp project.) However, if I turn the wifi off, then I get the following exception:

The pipe is being closed. (Exception from HRESULT: 0x800700E8).

Googling around, I see the suggestion that this is due to the Geolocator calling the Location API and getting a HRESULT_FROM_WIN32(ERROR_NO_DATA), and then mapping it to 'The Pipe is Being Closed' inadvertently.

That's a faintly ominous prospect, because it suggests to me that what I'm trying to do may not be something this device is designed for.

Can anyone help me out on whether this is actually a thing that even should be possible? That is, is it reasonable for me to expect that the geolocation plugin will work without a connection, or is that not a thing that it is supposed to do?

Best Answer


Sign In or Register to comment.