0

I am following the guide here, but I am using a C++ WinRT UWP project to consume the C# component instead of the C++ WinRT console project in the guide. However, it failed to add the C# component project as a project reference. enter image description here

My .csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <TargetFramework>net6.0-windows10.0.22000.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>   
      <CsWinRTComponent>true</CsWinRTComponent>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.1" />
  </ItemGroup>

</Project>

My Solution structure: enter image description here

I also tried to add the winmd file from the C# component, but I am stuck when adding

    <Extensions>
        <Extension Category="windows.activatableClass.inProcessServer">
            <InProcessServer>
                <Path>WinRT.Host.dll</Path>
                <ActivatableClass ActivatableClassId="CSharpComponent.Class1" ThreadingModel="both" />
            </InProcessServer>
        </Extension>
    </Extensions>

to package.appxmanifest. It fails to compile with this enter image description here

sz ppeter
  • 1,698
  • 1
  • 9
  • 21

0 Answers0