Calling metro app dll function from metro app C# app RRS feed

  • Question

  • Hi All,

    I have created C++ dll of Metro App.

    In this dll, I have exported some functions.

    In these functions I performed Async operations and fill the Structure get as an input.

    I call this function from C# Metro app.

    But, when function returns from the call, I get structure empty.

    Only those members of structure are filled which are filled outside Async operations.

    If any one have idea about it, then please help me.

    I want to fill the structure in function from dll by reading file and return the structure.

    Thanks & Regards,


    Wednesday, July 25, 2012 2:31 PM


All replies

  • Hello,

    How do you define the struct, I would suggest you to use the value struct instead of native struct.
    Please check this section.
    Method that returns a custom value struct

    Best regards,

    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, July 26, 2012 8:48 AM
  • Hi Jesse Jiang,

    Thanks for your reply.

    Yes, my structure is native structure and I have converted it in C# for C# app.

    I gone through the link.

    It is helpful.

    But, I need to fill the structure by reading data from file, which required Async operations.

    And we can't modify variables inside Async code that was the main problem.

    Waiting for your reply.



    Thursday, July 26, 2012 2:41 PM
  • Hi,


    I think you should return the modified value in your async function.


    Best regards,


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Jesse Jiang Thursday, August 2, 2012 7:15 AM
    Monday, July 30, 2012 7:20 AM
  • I'm not sure I'm following what the issue you're having problems with is. In general, you're going to want to use async/await on the C# side of things and return an IAsyncOperation<YourType^>^ from the C++/CX method.

    E.g. http://blogs.msdn.com/b/pfxteam/archive/2011/11/11/how-to-use-c-amp-from-c-using-winrt.aspx

    Inside your create_async lambda in C++/CX you can use blocking operations to wait for the file IO to complete since you won't be on the UI thread.

    Tuesday, July 31, 2012 12:02 AM