C# ReverseGeocodeCurrentLocation错误

C# ReverseGeocodeCurrentLocation错误,c#,android,xamarin,C#,Android,Xamarin,我现在的职位是自动定位。我在电话上直接编译时遇到了这个异常。但是当我在模拟器上编译时,它工作得非常好 问题出现在这一行: IList<Address> addressList = await geocoder.GetFromLocationAsync(_currentLocation.Latitude, _currentLocation.Longitude, 10); IList地址列表= 等待geocoder.GetFromLocationAsync(_c

我现在的职位是自动定位。我在电话上直接编译时遇到了这个异常。但是当我在模拟器上编译时,它工作得非常好

问题出现在这一行:

IList<Address> addressList =
            await geocoder.GetFromLocationAsync(_currentLocation.Latitude, _currentLocation.Longitude, 10);
IList地址列表=
等待geocoder.GetFromLocationAsync(_currentLocation.Latitude,_currentLocation.Latitude,10);
完整的方法是:

async Task<Address> ReverseGeocodeCurrentLocation()
    {
        Geocoder geocoder = new Geocoder(this);

        IList<Address> addressList =
            await geocoder.GetFromLocationAsync(_currentLocation.Latitude, _currentLocation.Longitude, 10);

        Address address = addressList.FirstOrDefault();
        return address;
    }
异步任务ReverseGeocodeCurrentLocation()
{
Geocoder Geocoder=新的Geocoder(本);
IList地址列表=
等待geocoder.GetFromLocationAsync(_currentLocation.Latitude,_currentLocation.Latitude,10);
Address=addressList.FirstOrDefault();
回信地址;
}

如何解决此问题?

单击“中断”。查看堆栈跟踪并准确确定导致异常的行。使用调试器找出哪个值为null,然后找出原因。@Jason,这一行导致异常:
IList addressList=await geocoder.GetFromLocationAsync(_currentLocation.Latitude,_currentLocation.Longitude,10)
你确定_currentLocation有值吗?@Jason,我在手机上编译时它是空的。但是当我在emulator上编译时,会有一些值,它会工作。您如何获得_currentLocation?您确定要在清单中请求正确的权限吗?单击“中断”。查看堆栈跟踪并准确确定导致异常的行。使用调试器找出哪个值为null,然后找出原因。@Jason,这一行导致异常:
IList addressList=await geocoder.GetFromLocationAsync(_currentLocation.Latitude,_currentLocation.Longitude,10)
你确定_currentLocation有值吗?@Jason,我在手机上编译时它是空的。但是当我在emulator上编译时,会有一些值,它会工作。您如何获得_currentLocation?您确定要在清单中请求正确的权限吗?