Skip to content

WinRT.ActivationFactory threw TypeInitializationException if try press Win + E to activate the application #3436

@zhuxb711

Description

@zhuxb711

Describe the bug

Replace the default settings in Registry at HKEY_CLASSES_ROOT\Folder\shell\opennewwindow\command to activate the application though press Win + E.

However, app that use Windows App Sdk could not be activated at this situation. TypeInitializationException was threw in AppInstance.GetCurrent(), message: 0x80040154 (REGDB_E_CLASSNOTREG).

Just to mention that activate the application though command line will not raise any exception.

   at WinRT.ActivationFactory`1.As(Guid iid)
   at Microsoft.Windows.AppLifecycle.AppInstance.Make___objRef_global__Microsoft_Windows_AppLifecycle_IAppInstanceStatics()
   at Microsoft.Windows.AppLifecycle.AppInstance.get__objRef_global__Microsoft_Windows_AppLifecycle_IAppInstanceStatics()
   at Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent()
   at CommandLineTest.Program.Main(String[] args)
   at C:\Users\zrfcfgs\source\repos\CommandLineTest\CommandLineTest\Program.cs : Line 46

Steps to reproduce the bug

  1. Download demo application
  2. Run the demo application and click "Click to Register" button
  3. Elevated requested just approve it (if UAC enabled)
  4. Related data was written into registry
  5. Close the application and press Win + E to activate the application
  6. Visual Studio was requested to debug
  7. See the exception
  8. Don't forget to click "Click to Unregister" to restore the registry after investigation

Expected behavior

AppInstance.GetCurrent() should not threw any exception

Screenshots

No response

NuGet package version

Windows App SDK 1.2.3: 1.2.230118.102

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

Demo application is in here:
CommandLineTest.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions