Hello,
Welcome to Microsoft Q&A!
Currently, it seems that it is not able to directly add a C++/WinRT component as a reference to a C# UWP app directly via Visual Studio. But you could do this manually by modifying the csproj file and the manifest file. You could go through this Github link: Unable to add C++/WinRT Runtime Component to UWP C# Application . In that link, Code-ScottLe tried to modify the csproj file and Scottj1s gives suggestions about how to make it work.
In short, you need to modify the c# project and adding
<ItemGroup>
<ProjectReference Include="..\projectname\project.vcxproj" />
</ItemGroup>
And then change the c# manifest:
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>projectname.dll</Path>
<ActivatableClass ActivatableClassId="projectname.classname" ThreadingModel="both"/>
</InProcessServer>
</Extension>
</Extensions>
For more details, please go through the link: Unable to add C++/WinRT Runtime Component to UWP C# Application
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.