How to fix System.TypeInitializationException of WinRT.ActivationFactory for Azure.Communication.Service.WindowsClient classes

Kateryna Novak 10 Reputation points
2023-12-28T17:46:32.17+00:00

Hi!

I recently upgraded the project that uses Azure.Communication.Service.WindowsClient to .NET 8 and the latest Windows SDK. It was working fine; I was able to join the Teams meeting. After the latest Windows update installation, I started to receive the following exceptions:

The type initializer for 'WinRT.ActivationFactory1' threw an exception.System.TypeInitializationException: The type initializer for 'WinRT.ActivationFactory1' threw an exception.---> System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName)at WinRT.ActivationFactory1..ctor()at WinRT.ActivationFactory1..cctor()--- End of inner exception stack trace ---at WinRT.ActivationFactory`1.ActivateInstanceIat Azure.Communication.Calling.WindowsClient.CallClientOptions..ctor()

All the following code fails after this, and the application does not work.

What could be the reason, and how can I fix it? I would appreciate any suggestions.

I'm using the following versions of the platform and packages:

Application target platform: net8.0-windows10.0.22621.0

Azure.Communication.Calling.WindowsClient v1.3.0

Microsoft.WindowsAppSDK v1.4.231115000

Microsoft.Windows.SDK.BuildTools v10.0.22621.2428

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
847 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. brtrach-MSFT 16,121 Reputation points Microsoft Employee
    2023-12-30T05:11:04.9333333+00:00

    @Kateryna Novak The System.TypeInitializationException you’re encountering is typically thrown when a static constructor throws an exception, or when some static field initializer does. In your case, it seems to be related to the WinRT.ActivationFactory1 class.

    This issue might be due to the following reasons:

    1. The class you’re trying to instantiate is not registered. This is indicated by the System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)) error.
    2. There might be some access denied issues as mentioned in a similar issue on GitHub.

    Here are a few suggestions that might help you resolve this issue:

    0 comments No comments

  2. Lahiru Senevirathne 0 Reputation points
    2024-07-23T14:50:36.8733333+00:00

    @Kateryna Novak Were you able to fix this issue. I am facing a similar issue when running in a windows container.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.