locked
Interop Between C# (.NET) IStream and C++ COM IStream

    Question

  • Mornin',

    I've got a managed C# object that implements System.Runtime.InteropServices.ComTypes.IStream. I would like to pass this into a C++ function to ultimately obtain a COM IStream* that I can use in the C++ module. 

    I can easily do this in desktop apps, but the runtime extensions for C++/CX don't include an IStream "interface class" I can use to specify as the argument type for the stream. Should I simply pass the C# stream to my C++ module as a generic managed Object and use a reinterpret_cast to get the COM IStream? That does seem to work, but I think it would be safer if I could somehow specify in the C++ class declaration that the managed object must implement IStream. 

    Thanks much!

    Peter


    • Edited by pnm655 Saturday, April 04, 2015 4:02 PM
    Saturday, April 04, 2015 3:49 PM