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

[BUG] AIDevGallery Runtime Error at startup (Class Not Registered) #276

Open
manoj-jain-techporch opened this issue Mar 5, 2025 · 7 comments
Labels
🐛bug Something isn't working

Comments

@manoj-jain-techporch
Copy link

Describe the bug
Able to download and compile the AIDevGallery application. When I run this the application it crashes with following error:

Application: AIDevGallery.exe
CoreCLR Version: 9.0.225.6610
.NET Version: 9.0.2
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at WinRT.ActivationFactory.Get(String typeName, Guid iid)
at Microsoft.Windows.AppLifecycle.AppInstance.get__objRef_global__Microsoft_Windows_AppLifecycle_IAppInstanceStatics()
at Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent()
at AIDevGallery.Program.DecideRedirection() in D:\Proj\ai-dev-gallery-main\AIDevGallery\Program.cs:line 48
at AIDevGallery.Program.Main() in D:\Proj\ai-dev-gallery-main\AIDevGallery\Program.cs:line 29

NOTE: When I downloaded the same "precompiled" app from Windows Store on the same test system it runs fine.

Test system has WindowsAppSdk [1.7 Experimental3 (1.7.250127003-experimental3)] X64 installed and has DEVELOPER mode enabled.

To Reproduce
Steps to reproduce the behavior:

  1. Compile APP with no change using VS2022 and latest WindowsAppSDK installed
  2. Copy application to test system (has Intel Integrated GPU and NPU)
  3. Double-click on APP
  4. See error in Windows Event Viewer

Expected behavior
Hoping to see the APP UI

Screenshots

Please complete the following information:

  • App Version [e.g. 0.3.6.0 from the Microsoft Store] works fine
  • VS 2022 v17.13.2 installed on development system

Additional context
Not sure if the application version that we compiled ourselves need to be registered on the test system before it is allowed to run!

@manoj-jain-techporch manoj-jain-techporch added the 🐛bug Something isn't working label Mar 5, 2025
@azchohfi
Copy link
Contributor

azchohfi commented Mar 5, 2025

AI Dev Gallery is a packaged application (MSIX), and it does not support running the exe from the bin folder manually. It needs App identity, so it needs to be installed from the MSIX itself.
I'm assuming you are copying the bin folder, so please correct me if this assumption is incorrect.
Instead, try right clicking on the AIDevGallery project in VS, then click on "Package and Publish" -> "Create App Packages...". The follow the screen and copy the MSIX instead, wherever you chose to generate it.
I hope this helps! Let us know if this works.

@manoj-jain-techporch
Copy link
Author

Thanks Alex.

Yes. We are running the EXE from the bin folder as-is. That must be the bug. Let me try and confirm.

So do all C# WindowsAppSDK samples (like ChatAppGenAI etc) needs to be MSIX? Are these C# samples that can run as standard desktop apps (exe)?

Thanks for the prompt response.

@azchohfi
Copy link
Contributor

azchohfi commented Mar 5, 2025

Running as an MSIX is particular to the AI Dev Gallery itself, since we use APIs that require App Identity.
So... there should be nothing blocking the exported apps to run in an unpackaged context, but we do not specifically block samples from using APIs that require identity. Therefore, it might work, but we don't guarantee it 😅

Just for testing purposes, I just exported the Chat Sample with Phi 4 and it worked fine as non-packaged. Yay! 🥳

In order to do this, all you need to do is add this property to your exported csproj:

<WindowsPackageType>None</WindowsPackageType>

And change the deployment setting in the dropdown, in Visual Studio, when deploying:
Image

Here is a link to the documentation:
https://learn.microsoft.com/en-us/windows/apps/winui/winui3/create-your-first-winui3-app#unpackaged-create-a-new-project-for-an-unpackaged-c-or-c-winui-3-desktop-app

@manoj-jain-techporch
Copy link
Author

Thanks Alex, Let us try this.

You have been very helpful!

@manoj-jain-techporch
Copy link
Author

BTW - If we do create a MSIX pkg, does it have to be signed (even if we use our company valid SPC)? The unsigned MISX failed installed and reported that the package has to be signed.

When we tried the "unpackaged" format and launch the EXE directly, it now shows an error that the system is missing:

Windows Runtime Version 1.5 (MSIX package version >= 5001.119.156.0)

and asks us to install WindowsAppSDK - which is already installed. We tried reinstalling it again from the link but still the same thing.

@azchohfi
Copy link
Contributor

azchohfi commented Mar 6, 2025

You would need to make sure that the WinAppSDK is installed. Docs:
https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/deployment-architecture
As well as the version of .Net that you are using.

If you want to make it completely installable by itself, you could do self-containment (both WinAppSDK and .Net).
To self-contain the WinAppSDK, which I also just tried locally, worked fine:

<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

Docs:
https://learn.microsoft.com/en-us/windows/apps/package-and-deploy/self-contained-deploy/deploy-self-contained-apps
https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/deployment-architecture#additional-requirements-for-unpackaged-apps

Same for .Net (but not as simple to keep the binary size small):
https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained

I would not recommend the self-contained route if not absolutely necessary, since patches (security) to the WinAppSDK would not be possible without recompiling and redistributing your app.

@manoj-jain-techporch
Copy link
Author

Hmm. That is strange then because the .NET Core version and WinndowsAppSDK that we have compiled with are installed on that system. Let us check everything again.

Thanks again for your prompt responses :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants