If you try to add a COM interface to the base class template of a XAML-based class, you will get a static assert error. This is the case even if you include unknwn.h before any C++/WinRT headers.
Reproducible example
In the WinUI 3 blank project, modify the MainWindow class so that it tries to implement a COM interface, e.g., IInitializeWithWindow:
Error: static_assert failed: "Class must derive from implements<> or ClassT<> where the first template parameter is the derived class name, e.g. struct D : implements<D, ...>");
Version
2.0.220110.5
Summary
If you try to add a COM interface to the base class template of a XAML-based class, you will get a static assert error. This is the case even if you include
unknwn.h
before any C++/WinRT headers.Reproducible example
In the WinUI 3 blank project, modify the
MainWindow
class so that it tries to implement a COM interface, e.g.,IInitializeWithWindow
:Expected behavior
I'd expect the code to compile.
Actual behavior
Error: static_assert failed: "Class must derive from implements<> or ClassT<> where the first template parameter is the derived class name, e.g. struct D : implements<D, ...>");
Additional comments
No response