Bing Map throws exception in 'Windows Runtime Component' project

0

First of all I want to apologize for the English.
I'am develop windows 8.1 store app. On C++/CX language. My solution contains several projects. One of projects has the 'Windows Runtime Component' type, and perform geocoding and reverse geocoding.
For a geocoding I use 'Bing Maps SDK for Windows 8.1 Store apps'(link).
Here's my algorithm:

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)
        {
        //
        }
    });
}

I've got the problem in this line:

Map^ map = ref new Map();

It always generates an exception with text:
"Platform::DisconnectedException ^ at memory location 0x0396DF80.
HRESULT:0x80010108 The object invoked has disconnected from its clients.
WinRT information: The object invoked has disconnected from its clients."
But I noticed something weird. If add project to the solution which contains UI(xaml), my code in this project works perfectly fine, without any exceptions.
Can somebody specify an error to me?
Or give the explanation for this strange behavior.
There is probably other methods to perform geocoding for windows 8.1 store apps, which I don't know yet.
Thanks.

c++
windows-runtime
windows-store-apps
c++-cx
bing-maps
asked on Stack Overflow Nov 7, 2016 by Igor Taranenko • edited Nov 9, 2016 by Igor Taranenko

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0