Bug: COMException (0x80040154 - REGDB_E_CLASSNOTREG) after migrating NetProjectionSample to .NET 8.0
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 665
- Forks
- 134
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 32
Description
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
- 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> - Also, update the Target Framework for the SimpleMathProjection to
net8.0-windows10.0.19041.0. - 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" /> - Rebuild both solution.
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ConsoleAppSample and SimpleMathProjection project files, compare the net6.0 and net8.0 target frameworks, and reproduce the failure after updating Microsoft.Windows.CsWinRT to 2.2.0. Investigate the SimpleMathComponent activation path and its registration context. Done means ConsoleAppSample runs on net8.0 without the REGDB_E_CLASSNOTREG exception and can use the component.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100