"Pipe is being closed" when using the WinRT Geolocator

6

When I use the WinRT Geolocator, I sporadically get the error:

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

Again, this is sporadic. Any suggestions?

Windows.Devices.Geolocation.Geoposition _Postion = null;
try
{
    var _Locator = new Windows.Devices.Geolocation.Geolocator();
    _Postion = await _Locator.GetGeopositionAsync();
}
catch { /* continue, null okay */ }

if (_Postion == null)
{ 
    /* use alternate */ 
}
else
{
    /* use location */ 
}

This is in the simulator, but also when run on local machine. Usually this error will NOT result in a break. It just ends the app suddenly. When it does result in a break. That is the resulting error.

c#
geolocation
windows-runtime
asked on Stack Overflow Jun 27, 2012 by Jerry Nixon • edited Jun 28, 2012 by Jerry Nixon

3 Answers

1

I figured out that this happened when your localization is set as "simulated", if you are running your app using device simulator you may disable this by click in world icon (between display and camera settings), then uncheck "Use simulated location" option

answered on Stack Overflow Jul 24, 2012 by Jonathan Escobedo
0

I think the root cause for this issue is that GeoLocator is using Location API.

The error you are getting is HRESULT_FROM_WIN32(ERROR_NO_DATA), which seems to map to the friendly (but unhelpful, in this case) string "The pipe is being closed." That's the expected error when the platform doesn't see your sensor providing a valid report.

answered on Stack Overflow Jul 25, 2013 by user844541
0

I also faced a similar sporadic exception in my project. Look at the image screenshot I attached.enter image description here

Here is the solution which worked for me, but I am not sure whether it will work for others.

This was my code before:

Geolocator loc = new Geolocator();
try
{
      loc.DesiredAccuracy = PositionAccuracy.High;

      Geoposition pos = await loc.GetGeopositionAsync();
      var lat = pos.Coordinate.Point.Position.Latitude;
      var lang = pos.Coordinate.Point.Position.Longitude;
      Status = loc.LocationStatus;

      return GetGpsInfoObject(pos);
}
catch (System.UnauthorizedAccessException)
{
      return null;
}

I changed the code to:

Geolocator loc = new Geolocator();
try
{
       loc.DesiredAccuracy = PositionAccuracy.High;

       Geoposition pos = await loc.GetGeopositionAsync();
       var lat = pos.Coordinate.Point.Position.Latitude;
       var lang = pos.Coordinate.Point.Position.Longitude;
       Status = loc.LocationStatus;

       return GetGpsInfoObject(pos);
}
catch (Exception)
{
          return null;
}
answered on Stack Overflow May 7, 2015 by Aswajith • edited Dec 14, 2015 by DisplayName

User contributions licensed under CC BY-SA 3.0