none
"*.idl", ".cs" and "c++", I need more information of what I am working with to figure out what I need to know, please help. RRS feed

  • Question

  • Hi guys:

    I am currently in a project that calls c++winrt from c# thru IDL, I have a const static string from C++ side and I am returning it as an winrt::hstring thru idl to C#. However, when I try to access this const static I am getting a cast error. This is very confusing, since if I move these static strings to another runtime class in the IDL, I wasn't getting this cast error, the only difference that can remotely hint the culprit to me is the using of optional template class in C++, but I am a very rookie windows developer and don't know anything about windows. I have tried a lot of googling and it all landed me in sandbox jail.

    An exception of type 'System.InvalidCastException' occurred in App1.exe but was not handled in user code
    Unable to cast object of type 'System.__ComObject' to type 'MySDK.IMyInformationStatics'.

    I would also want to know where would I be able to find a systematic tutorial that I can learn windows development, I know a bit of C# and around 2 years of dedicated C++, I have been working with using C++winrt in C#, any recommendation would be greatly appreciated.


    • Moved by CoolDadTx Wednesday, October 9, 2019 1:38 PM WinRT related
    Tuesday, October 8, 2019 4:26 PM

All replies

  • Hi RookieFrankie,

    Thank you for posting here,

    According to your problem, I have a question to confirm with you.

    Could you provide some related code here? It will help us to make a test and reproduce your problem.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 9, 2019 8:41 AM