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

Failure when using SystemNavigationManager.GetForCurrentView() #15289

Closed
jeromelaban opened this issue Jan 31, 2024 · 1 comment · Fixed by #15376
Closed

Failure when using SystemNavigationManager.GetForCurrentView() #15289

jeromelaban opened this issue Jan 31, 2024 · 1 comment · Fixed by #15376
Assignees
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working

Comments

@jeromelaban
Copy link
Member

Current behavior

The following:

SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

Fails in the playground canary:

System.Collections.Generic.KeyNotFoundException: Arg_KeyNotFoundWithKey, Microsoft.UI.WindowId
dotnet.native.js:8    at System.Collections.Generic.Dictionary`2[[Microsoft.UI.WindowId, Uno, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null],[Windows.UI.ViewManagement.ApplicationView, Uno, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null]].get_Item(WindowId key)
dotnet.native.js:8    at Windows.UI.ViewManagement.ApplicationView.GetForWindowId(WindowId windowId)
dotnet.native.js:8    at Windows.UI.ViewManagement.ApplicationView.GetForCurrentView()
dotnet.native.js:8    at Uno.UI.Demo.App.OnLaunched(LaunchActivatedEventArgs e)

Expected behavior

No failure

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

5.2.0-dev.412

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@jeromelaban jeromelaban added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jan 31, 2024
@Youssef1313
Copy link
Member

This generally means that GetForCurrentView is called very early, before the window is initialized.

@MartinZikmund MartinZikmund added difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers and removed triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants