How to get GPS location from built-in surface pro GPS without internet connection

Anders F 0 Reputation points
2024-05-29T12:53:10.7766667+00:00

I need to be able to get the gps location from the built-in gps on a surface pro tablet. This is a WPF application and all my research says to use the GeoCoordinateWatcher class in System.Device.Location. This only seems to work when the tablet is connected to wifi and I did see on stack overflow that GeoCoordinateWatcher can't work without internet connection. Is this true that there's no way to get GeoCoordinateWatcher to work without internet connection, and if so, how would I go about getting the devices location using just the built-in gps without needing an internet connection?

Community Center | Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 36,766 Reputation points MVP Volunteer Moderator
    2024-05-29T16:29:27.4233333+00:00

    Hello @Andres F,

    welcome to this moderated Azure community forum.

    It seems it’s only the LTE/4g version that has the GPS. Are you sure your device has a GPS?

    If so, the GeoCoordinateWatcher is only available for .Net Framework 4.8.1 so you have a challenge when using .Net Core.

    As an alternative can you check if your GPS is available as a COM port within your Surface?

    In that case, check out the serial port library (eg. in .Net 8).

    GPS devices normally output a stream of ASCII messages in the NMEA format.

    Check out this blog post with some background information (like checking the NMEA message stream).

    From there, check out this NuGet package containing a parser for the most popular NMEA messages, based on this GitHub repo.

    This is a little side-step but it gives you more control over the GPS information, depending on the availability of the COM port support.

    Update: there is a port for .Net Core available as open source: https://github.com/dotMorten/System.Device Can you confirm this works for you?


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.