Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zhuxb711 opened this issue Feb 15, 2023 · 3 comments · Fixed by microsoft/devhome#3437

Comments

@zhuxb711
Copy link

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

@gabbybilka
Copy link
Member

As the app is packaged, this isn't possible as Win+E is trying to run a Win32 process. This might work if the app is unpackaged.

@zhuxb711
Copy link
Author

zhuxb711 commented Feb 17, 2023

@gabbybilka However, packaged application supports Alias which is used to support command line activation. We could set the alias path to registry. That work as expected for me.

@gabbybilka
Copy link
Member

@codendone ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants