Bing Map在“Windows运行时组件”中引发异常'项目

时间:2016-11-07 13:21:06

标签: c++ windows-runtime windows-store-apps c++-cx bing-maps

首先,我想为英语道歉 我正在开发Windows 8.1商店应用。在C ++ / CX语言上。我的解决方案包含几个项目其中一个项目具有' Windows运行时组件' 类型,并执行地理编码和反向地理编码。
对于地理编码,我使用Bing Maps SDK for Windows 8.1 Store应用程序'(link)。
这是我的算法:

void addressByLocation(double latitude, double longitude)
{
    ResourceLoader^ loader = ref new ResourceLoader();
    String^ credentials = loader->GetString("BingMapCredentials");

    Location^ location = ref new Location(latitude, longitude);
    ReverseGeocodeRequestOptions^ requestOptions = ref new ReverseGeocodeRequestOptions(location);

    Map^ map = ref new Map();
    map->Credentials = credentials;

    SearchManager^ searchManager = map->SearchManager;
    task<LocationDataResponse^> reverseGeocodeTask(searchManager->ReverseGeocodeAsync(requestOptions));
    reverseGeocodeTask.then([=](LocationDataResponse^ response)
    {
        if (!response->HasError)
        {
        //
        }
    });
}

我在这一行中遇到了问题:

Map^ map = ref new Map();

它总是生成一个带有文本的例外:
&#34; Platform :: DisconnectedException ^在内存位置0x0396DF80 HRESULT:0x80010108调用的对象已与其客户端断开连接 WinRT信息:调用的对象已与其客户端断开连接。&#34;
但我发现了一些奇怪的东西。如果将项目添加到包含UI(xaml)的解决方案,则此项目中的代码完全正常,没有任何例外。
有人可以给我指一个错误吗?
或者给出这个奇怪行为的解释 可能还有其他方法可以为Windows 8.1商店应用程序执行地理编码,我还不知道 感谢。

0 个答案:

没有答案