question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling ApplicationView.GetForCurrentView throws an error

See original GitHub issue

Describe the bug

Calling ApplicationView.GetForCurrentView() in App.OnLaunched() throws this error:

System.Runtime.InteropServices.COMException: 'Element not found. (0x80070490)'

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Create a Blank, Packaged WinUI 3 C# app
  2. Add the following code to beginning of the App.OnLaunched method in App.xaml.cs
ApplicationView.PreferredLaunchViewSize = new Size(500, 800);
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(500, 800));

Expected behavior

App launches without an uncaught exception.

Version Info

NuGet package version: 3.0.0-preview1.200515.3

Windows 10 version Saw the problem?
Insider Build (xxxxx)
November 2019 Update (18363) Yes
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Mobile
Xbox
Surface Hub
IoT

Additional context

This issue does not occur when using the non-WinUI C# Desktop App project template.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

InputPane.GetForCurrentView throws COMException ...
GetForCurrentView throws COMException (0x80070490): Element not found ... However the call to InputPane inputPane = InputPane. ... Error(ex.
Read more >
calling ApplicationView::GetForCurrentView() returns error ...
1 Answer 1 ... If you want to resize your app, please call TryResizeView method after setting preferred min Size. auto view =...
Read more >
ApplicationView.GetForCurrentView() occasionally throws " ...
ApplicationView avCurrent = ApplicationView.GetForCurrentView(); The above code occasionally throws the following exception: System.
Read more >
Setting minimum window size?
ApplicationView appView = ApplicationView.GetForCurrentView();. appView.Title = "Custom Title";. It's causing a runtime error when deployed ...
Read more >
October | 2013
It throws! Apparently, it's not appropriate to call newView.IsMain at that point but I didn't find that doc'd anywhere so it came as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found