Skip to content

Integration Issues: C++/WinRT Runtime Component & C# WinUI 3 Project on .NET 9 – WinMD and C++/CLI Interop Problems #10400

@KrishBaidya

Description

@KrishBaidya

Description:

I'm encountering significant challenges when integrating a C++/WinRT Runtime Component into my C# WinUI 3 project, which is targeting .NET 9. It appears that .NET 9 does not support referencing Windows Metadata (.winmd) files directly, leading to errors during compilation. Additionally, using a C++/CLI wrapper to bridge the gap is problematic due to incompatibilities between C++/WinRT and /clr modes. I've attached a screenshot of the error message ("The method or operation is not implemented") encountered when creating a new C++/WinRT Runtime Component project.

Steps to Reproduce:

  1. Create a new C++/WinRT Runtime Component project using the WinUI 3 template in Visual Studio.
  2. Attempt to reference the generated .winmd file from a C# WinUI 3 project targeting .NET 9.
  3. Encounter the error:

MyNewProject.winmd cannot be referenced. Referencing a Windows Metadata component directly when targeting .NET 5 or higher is not supported. For more information, see https://aka.ms/netsdk1130

  1. Remove App.xaml/App.xaml.cpp from the C++/WinRT project and try referencing it, but the issue persists.
  2. Attempt to create a C++/CLI wrapper to bridge to the C++/WinRT code, but this fails due to the incompatibility of C++/WinRT code with the /clr environment required by C++/CLI.
  3. When creating a new C++/WinRT Runtime Component project, a separate error appears ("The method or operation is not implemented"). See attached screenshot.

Image

Expected Behavior:

  • A clear integration path where the C++/WinRT Runtime Component can be consumed by a C# WinUI 3 project targeting .NET 9 without running into the WinMD reference limitation.

Steps I've Already Tried:

  • Verified that all required Visual Studio workloads and components are installed and up to date.
  • Attempted using multiple project templates (both Runtime Component and Blank App templates).
  • Explored creating a C++/CLI wrapper, which ultimately failed due to the incompatibility between /clr and C++/WinRT code.

Any assistance or insights into a viable integration strategy would be greatly appreciated. Thank you for your work on WinUI 3 and the Windows App SDK!

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs to be triaged by the area owners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions