Skip to content

Bug: COMException (0x80040154 - REGDB_E_CLASSNOTREG) after migrating NetProjectionSample to .NET 8.0 #2018

@Nicococoooo

Description

@Nicococoooo

Description

When I update the NetProjectionSample project from net6.0-windows10.0.19041.0 to net8.0-windows10.0.19041.0, a System.Runtime.InteropServices.COMException is thrown at runtime. The error message is Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).

This error occurs in the ConsoleAppSample when trying to create an instance of the SimpleMathComponent.

Steps To Reproduce

  1. In the ConsoleAppSample project, change the Target Framework in the project file (.csproj) from:<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework> to <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
  2. Also, update the Target Framework for the SimpleMathProjection to net8.0-windows10.0.19041.0.
  3. Update the Nuget package for the SimpleMathProjection from:<PackageReference Include="Microsoft.Windows.CsWinRT" VersionOverride="1.3.5" /> to <PackageReference Include="Microsoft.Windows.CsWinRT" VersionOverride="2.2.0" />
  4. Rebuild both solution.
  5. Run the ConsoleAppSample.

Expected Behavior

The ConsoleAppSample should run successfully without any exceptions, just as it does when targeting net6.0. The application should be able to activate and use the SimpleMath component.

Version Info

CsWinRT Version: 2.2.0
Target Framework: net8.0-windows10.0.19041.0
Windows SDK Version: 10.0.19041.0
Visual Studio Version: 17.14.8

Additional Context

This issue seems to be related to the .NET 8.0 upgrade. The COM activation of the projected component fails, suggesting a potential issue with how the component is registered or activated in the context of a .NET 8.0 application. The project works perfectly fine on net6.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions