C#C
C#2y ago
11 replies
yambo

The type initializer for '<Module>' threw an exception.

Hello,
I am currently unit testing my solution (not much has been programmed at all) and a few days ago all my tests (1 test lol) ran perfectly fine.
Today I get this error (i also made another test project with a different testing framework, still same error):

System.TypeInitializationException : The type initializer for '<Module>' threw an exception.
---- System.TypeInitializationException : The type initializer for 'WinRT.ActivationFactory
1' threw an exception.
    -------- System.Runtime.InteropServices.COMException : Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))

A friend of mine can also reproduce this error.
All we have is a xUnit test project and a MAUI project with one class (no ui implementation at all)

Stack Trace: 
  ItemGroupDTOTests.VerifyItemGroupDTOHoldsInputValues()
  RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
  MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
  ----- Inner Stack Trace -----
  ActivationFactory
1.ActivateInstanceI
DeploymentInitializeOptions.ctor()
AutoInitialize.get_Options() line 44
AutoInitialize.AccessWindowsAppSDK() line 30
cctor()
----- Inner Stack Trace -----
Marshal.ThrowExceptionForHR(Int32 errorCode)
BaseActivationFactory.ctor(String typeNamespace, String typeFullName)
ActivationFactory
1.ctor()
  ActivationFactory
1.cctor()
Was this page helpful?