An exception is given when trying to manipulate UI when the packageCatalogUninstalling event is triggered WinUI

2024-12-03T19:14:54.59+00:00

Hello!
I'm testing an application that uses PackageCatalog.Uninstalling event and i would like to change the UI when this event is triggered but when i try to do it an exception is given. User's image

I also tried with a dispatcher but received another error
User's image

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
804 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
824 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Junjie Zhu - MSFT 19,751 Reputation points Microsoft Vendor
    2024-12-18T06:54:47.95+00:00

    Hello @Andre Luiz Bacelar Gonçalves de Menezes and @Anderson Rodrigues Cavalcante ,

    Welcome to Microsoft Q&A!

    According to the error message, the window has not been created yet.

    When uninstalling this app, the UI will be closed first, and then the packageCatalogUninstalling event will be triggered, so you will get an error when accessing the UI in the packageCatalogUninstalling event. This is an expected behavior because all UIs are destroyed.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.