Issues with Class Inheritance and ABIs


  • I was putting together a C++ WinRT Component library to help integrate XAML and Direct2D and had some problems this morning. The library worked fine when used from a basic C++ XAML app, but not from a C# one. With some help from Jeremiah Morrill I got this working, but I have a feeling I was hitting bugs that might not have been reported before.

    I had native code debugging turned on in my C# app. Original code is available here.

    One error I was getting was getting was that when my C# code included references to the C++ component - the app would crash in between my SwapChainBackgroundPanel constructor and the first layout round. The error I was getting was:

    The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

    It turned out the ref class I the library was exposing was inheriting from another one that was in a global namespace. The fix was to put the base class in the same namespace as the subclass.

    The other issue was with calling overridden methods of that subclass from the C# host app. I kept getting runtime errors like "Method 'Render' in ComImport class 'D2DRenderer.D2DRenderer' must implement an interface method." when trying to call these methods. The workaround was to expose methods in the C++ subclass from the library to the C# app or other hosts that are simple new methods that call the overridden ones.

    The fixed project is available here.

    Filip Skakun

    Tuesday, May 22, 2012 9:37 PM

All replies




    Did you have any addition question about this project or ABIs?


    Best regards,


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

    Thursday, May 24, 2012 2:46 AM
  • I would just like to know if I am crossing ABI boundaries when I interface between a native WinRT dll and a C# application and if what I found is a bug, temporary limitation of the platform or something we need to learn to live with? It seems like we can inherit from XAML control classes, but not arbitrary ones. Is there some documentation, article or blog post that talks about it?

    Filip Skakun

    Thursday, May 24, 2012 5:12 AM