You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason when I use ThemeSettings to watch the Changed event, the application crashes with an internal error from SDK.
It happens in two scenarios:
1 - When I use ThemeSettings like a local variable
2 - When I use ThemeSettings like a global variable in a single instance class
Steps to reproduce the bug
I create an app with two Pages and move back and forth between them.
First scenario you can use it like that in the Loaded event in the second Page.
if (this.XamlRoot != null && this.XamlRoot.ContentIslandEnvironment != null)
{
WindowId myWindowId = this.XamlRoot.ContentIslandEnvironment.AppWindowId;
var _themeSettings = ThemeSettings.CreateForWindowId(myWindowId);
if (_themeSettings != null)
{
_themeSettings.Changed += ThemeSettings_Changed;
}
}
In some moments the App Crashes...
The second scenario just replaces var _themeSettings for a global variable and moves the code to a singleton class. Both crashes the same way.
I suppose it can happen because the Changed event isn't explicitly unsubscribed... But I believe it's an unhandled exception in the SDK source code.
To solve the problem by now, I'm checking if _themeSettings is not null before CreateForWindowId and Unbscribe the Changed event in the Unload page Event, but I'm not sure if other crashes can reside.
Expected behavior
Do not crash the app.
Screenshots
No valuable information actually.
NuGet package version
WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
For some reason when I use ThemeSettings to watch the Changed event, the application crashes with an internal error from SDK.
It happens in two scenarios:
1 - When I use ThemeSettings like a local variable
2 - When I use ThemeSettings like a global variable in a single instance class
Steps to reproduce the bug
I create an app with two Pages and move back and forth between them.
First scenario you can use it like that in the Loaded event in the second Page.
In some moments the App Crashes...
The second scenario just replaces var _themeSettings for a global variable and moves the code to a singleton class. Both crashes the same way.
I suppose it can happen because the Changed event isn't explicitly unsubscribed... But I believe it's an unhandled exception in the SDK source code.
To solve the problem by now, I'm checking if _themeSettings is not null before CreateForWindowId and Unbscribe the Changed event in the Unload page Event, but I'm not sure if other crashes can reside.
Expected behavior
Do not crash the app.
Screenshots
No valuable information actually.
NuGet package version
WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response
The text was updated successfully, but these errors were encountered: