Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The name 'Console' does not exist in the current context In xamarin forms app

I am working on a app in Xamarin Forms that needs to get the geolocation data from the device and then put the geolocation coordinates into the forecast.io URL I am using the Geolocator plugin by James Montemagno and i'm using the code that the read me suggests, however I get the following error 4 times:

The name 'Console' does not exist in the current context

Here's my code:

using AppName.Data;
using Xamarin.Forms;
using Plugin.Geolocator;

namespace AppName.Radar
{    
    public partial class RadarHome : ContentPage
    {   
        public RadarHome()
        {    
            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = 50;

            var position = await locator.GetPositionAsync(timeout: 10000);

            Console.WriteLine("Position Status: {0}", position.Timestamp);
            Console.WriteLine("Position Latitude: {0}", position.Latitude);
            Console.WriteLine("Position Longitude: {0}", position.Longitude);
            var LatLong = position.Latitude + "," + position.Longitude;

            var browser = new WebView();
            browser.Source = "https://forecast.io/?mobile=1#/f/" + LatLong;

            Content = browser;   
        }
    }
}

I am using Visual Studio Update 3. Any ideas on what I'm doing wrong?

like image 770
Phoneswapshop Avatar asked Aug 23 '16 15:08

Phoneswapshop


1 Answers

The "Console" function is only available if you create a Console App(.NET Core) or (.Net Framework); so, if you for example create a Blank App, it is not going to work. But instead, you can use the Debug function.

like image 166
Ramtin Mir Avatar answered Sep 21 '22 00:09

Ramtin Mir