TypeInitializationException for WinRT.ActivationFactory (E_ACCESSDENIED)
DominicMaas opened this issue ยท 12 comments
Describe the bug
An exception from a deployed application. This is with Windows App SDK 1.2
Application: Muse.exe
CoreCLR Version: 6.0.922.41905
.NET Version: 6.0.9
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for '<Module>' threw an exception.
---> System.TypeInitializationException: The type initializer for 'WinRT.ActivationFactory`1' threw an exception.
---> System.UnauthorizedAccessException: Access is denied. (0x80070005 (E_ACCESSDENIED))
at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName)
at WinRT.ActivationFactory`1..ctor()
at WinRT.ActivationFactory`1..cctor()
--- End of inner exception stack trace ---
at WinRT.ActivationFactory`1.ActivateInstance[I]()
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions..ctor()
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.get_Options() in D:\a\Muse\Muse\Windows\out\nuget\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 44
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() in D:\a\Muse\Muse\Windows\out\nuget\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 30
at .cctor()
--- End of inner exception stack trace ---
Steps to reproduce the bug
n/a
Expected behavior
No response
Screenshots
No response
NuGet package version
None
Packaging type
Packaged (MSIX)
Windows version
Windows 10 version 21H2 (19044, November 2021 Update)
IDE
No response
Additional context
No response
I believe this affects Windows 10 users using 1.2.0. Looks like when installing 1.2.1 (even though the app is built against 1.2.0), it fixes the issue, and the application can launch again.
Can't see anything in the 1.2.1 release notes though...
Nah I think this is a bigger issue, maybe related to #3137 ? Or at least a few issues going on
I am experiencing this exact error. Windows 10 (Windows 10 Pro for Workstations 22H2). .NET 7.0 / Maui. The application never appears nor does it ever hit the first line of code in MainProgram.cs, which is MauiAppBuilder oBuilder = MauiApp.CreateBuilder();
It just started for a another member of the team when he was working on the application. When I build on my machine, the same error occurs. The code ran last week, now it does not, so something has changed. We trying to see what changes were made by reviewing source control. Any ideas of the root cause?
I am facing similar error with .NET Version 7.0.2
CoreCLR Version: 7.0.222.60605
.NET Version: 7.0.2
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for '' 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.ActivationFactory1.ActivateInstanceI
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions..ctor()
at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.get_Options()
@shantisharma I am facing similar error with .NET Version 7.0.2...
Are you running Win10? One possible reason for this symptom was due to a bug in Windows (one we couldn't workaround in WinAppSDK). A Windows servicing update to correct that just came out or will soon (I don't recall the exact date).
@pcxbrook I am experiencing this exact error. Windows 10 (Windows 10 Pro for Workstations 22H2). .NET 7.0 / Maui. The application never appears nor does it ever hit the first line of code in MainProgram.cs, which is MauiAppBuilder oBuilder = MauiApp.CreateBuilder();
Sounds like maybe a dupe of the (known issue #3137)[https://github.com//issues/3137#issuecomment-1332851404] Windows 10 needs the servicing update coming in Jan
@sachintaMSFT do you know how one can tell if that update's present on a system?
I too receive similar error on Windows 11 Pro Version 10.0.22631 Build 22631. It can start up in rider ok but running from debug folder throws this error.
Application: W.TemplateMessageClient.exe CoreCLR Version: 8.0.624.26715 .NET Version: 8.0.6 Description: The process was terminated due to an unhandled exception. Exception Info: System.TypeInitializationException: The type initializer for '<Module>' 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 WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName)
at WinRT.ActivationFactory1..cctor() --- End of inner exception stack trace --- at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions..ctor() at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.get_Options() in C:\Users\xyz\.nuget\packages\microsoft.windowsappsdk\1.5.240311000\include\DeploymentManagerAutoInitializer.cs:line 44 at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() in C:\Users\xyz\.nuget\packages\microsoft.windowsappsdk\1.5.240311000\include\DeploymentManagerAutoInitializer.cs:line 30 at .cctor() --- End of inner exception stack trace ---
I experience this in MAUI .net 8.0.0
@MikeHillberg @DrusTheAxe has this issue been fixed? | whats the latest update on this?
I too experience this, exes run from debug/release folders just crash with:
System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) at WinRT.BaseActivationFactory..ctor
Runs fine from VS2022, but cannot publish or run a windows exe!
My current workaround for this is to build and publish the windows exe using a github actions image (rather than my own machine):
see here
Why is this not fixed? I get it just by creating a new Maui project.
Win 11 (10.00.22000.0653)
Visual Studio 2022 (17.12.3)
.Net 8.0.111
Tried building in .Net 9 as well. Still an issue.
I believe this affects Windows 10 users using 1.2.0. Looks like when installing 1.2.1 (even though the app is built against 1.2.0), it fixes the issue, and the application can launch again.
Can't see anything in the 1.2.1 release notes though...
Since the original issue could work since 1.2.1 (which is actually a really old version for nowadays), will close this issue.
For anyone who still encounters COMException (0x80040154): Class not registered (or similar) issues:
Please note that the COMException is actually a issue that might have various reasons. So please open a new issue for your own scenario and attach the details for your project, rather than reopen this issue.