WinRT C++ IMap returning Windows Runtime Object instead of IDictionary into C#


  • We have a problem with a C++ Backend Library for our C# Windows Store Application.

    On the C++ side we have a property that is defined like this:

    property IMap<String^, IMap<String^, String^>^ >^   myVariable;

    On the C# side the property is correctly transformed to:

    public IDictionary<string, IDictionary<string, string>> myVariable { get; set; }

    The situation: while in debug (with a breakpoint set), you can see that the returned object from C++ is a Windows Runtime Object, instead of the expected Dictionary. I can iterate through the returned object and the code in the foreach loop executes successfully.

    WRO in Debug

    The problem: if I remove the breakpoint (but I am still in debug), the returned object does not have any information. It is not null, as I get no exception, but it is empty (the foreach loop does not execute -- the inner breakpoint is not reached).

    More information:

    • the Dictionary itself is part of a larger object;
    • the rest of the properties contain information;
    • in a C++ Windows Store Application the Dictionary (IMap) is correctly displayed (so the problem may be from the linking between C++ and C#);
    • I get the backend object using async Tasks:

    BiggerObject myObject = await Task.Factory.StartNew(() => { return clientInstance.GetMyObject(key); });

    Do you have any ideas why the Dictionary is not correctly recognized while in Debug and why it is empty while not in Debug?

    Thank you for your answers!

    Regards, Ionut

    Thursday, March 26, 2015 2:16 PM

All replies

  • Danila, personally i think its reasonable, C++ componment is kind of COM object with return value as Runtime object, should be able to see more detail if we click "Dymanic view". Not sure if there is some delay exist like you cannot get items immediately but you can see the items after 10ms while debugging stop at here.

    Friday, March 27, 2015 8:38 AM
  • Indeed, I can see the results using "Dynamic View". I will try to put in a delay after retrieving items.

    Will get back with the results. Thank you!

    Friday, March 27, 2015 8:44 AM
  • Unfortunately the delay did not return any results. I went from 20 ms to 1000 ms... the issue still persists.
    Friday, March 27, 2015 11:34 AM