C# System.UnauthorizedAccessException:&x27;位置UWP拒绝访问
我试着做一个简单的天气预报,但我有一个例外。 我已经激活了定位。我尝试在手机模拟器中运行,但不工作C# System.UnauthorizedAccessException:&x27;位置UWP拒绝访问,c#,uwp,C#,Uwp,我试着做一个简单的天气预报,但我有一个例外。 我已经激活了定位。我尝试在手机模拟器中运行,但不工作 使用系统; 使用System.Collections.Generic; 使用System.IO; 使用System.Linq; 使用System.Runtime.InteropServices.WindowsRuntime; 使用Windows基金会; 使用Windows。 使用Windows.UI.Xaml; 使用Windows.UI.Xaml.Controls; 使用Windows.UI.X
使用系统;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.Runtime.InteropServices.WindowsRuntime;
使用Windows基金会;
使用Windows。
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls;
使用Windows.UI.Xaml.Controls.Primitives;
使用Windows.UI.Xaml.Data;
使用Windows.UI.Xaml.Input;
使用Windows.UI.Xaml.Media;
使用Windows.UI.Xaml.Navigation;
命名空间TryToMakeWeatherApp
{
///
///可以单独使用或在框架内导航到的空页。
///
公共密封部分类主页面:第页
{
公共主页()
{
this.InitializeComponent();
}
专用异步无效按钮\u单击(对象发送方,路由目标)
{
var pos=await LocationManage.GetLocation();//我在这里获取错误信息
var lat=位置坐标纬度;
var lon=位置坐标经度;
var weather=WeatherMap.GetWeather(lat,lon).ToString();
WeatherTxt.Text=天气;
}
}
}
这是主页上的代码。
这是LocationManage类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Geolocation;
namespace TryToMakeWeatherApp
{
class LocationManage
{
public async static Task<Geoposition> GetLocation()
{
var accessStatus = await Geolocator.RequestAccessAsync();
var geolocator = new Geolocator { DesiredAccuracyInMeters = 0 };
var position = await geolocator.GetGeopositionAsync();
return position;
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用Windows.Devices.Geolocation;
命名空间TryToMakeWeatherApp
{
类位置管理
{
公共异步静态任务GetLocation()
{
var accessStatus=await geologitor.RequestAccessAsync();
var geolocator=新的geolocator{DesiredAccuracyNames=0};
var position=await geological.GetGeopositionAsync();
返回位置;
}
}
}
在您的软件包中。清单文件也必须打开此功能在您的软件包中。清单文件也必须打开此功能您是否尝试通过设置手动允许您的应用访问?我的应用未显示在列表中以授予权限。请不要忘记在用户拒绝权限的情况下进行测试。您是否尝试通过设置手动允许访问您的应用程序?我的应用程序未显示在列表中以授予权限。并且不要忘记在用户拒绝权限的情况下进行测试。您能告诉我清单中的具体位置吗?您能告诉我清单中的具体位置吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Geolocation;
namespace TryToMakeWeatherApp
{
class LocationManage
{
public async static Task<Geoposition> GetLocation()
{
var accessStatus = await Geolocator.RequestAccessAsync();
var geolocator = new Geolocator { DesiredAccuracyInMeters = 0 };
var position = await geolocator.GetGeopositionAsync();
return position;
}
}
}