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

System.AccessViolationException: 1.4.x broke creation of 2 Microsoft.Ui.Xaml.Window within Application's OnLaunched #9310

Closed
TomPMoleman opened this issue Jan 25, 2024 · 3 comments
Labels
area-Windowing closed-Duplicate Described behavior is already captured by another issue. team-Markup Issue for the Markup team

Comments

@TomPMoleman
Copy link

Describe the bug

Up till the last 1.3 version it was ok, to create 2 instances of a Microsoft.Ui.Xaml.Window within your Application's OnLaunched method (or later down the call stack).
However, SDK 1.4.0 broke this, and you'll inevitably encounter a System.AccessViolationException!

Steps to reproduce the bug

  1. Create new WinUi3 project
  2. Raise 'Microsoft.WindowsAppSDK' NuGet version to at least 1.4.230822000
  3. Open App.xaml.cs class
  4. Adapt OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) as to instantiate a new instance of Microsoft.Ui.Xaml.Window twice
  5. Run application
  6. => Please note, that shortly afterwards a System.AccessViolationException will be thrown:
    Exception thrown at 0x00007FFD2D05DE84 (Microsoft.UI.Windowing.Core.dll) in [...].exe: 0xC0000005: Access violation reading location 0x0000000000000030.

Expected behavior

Just like prior to version 1.4.0, no System.AccessViolationException shall be thrown.

Screenshots

image

NuGet package version

Windows App SDK 1.4.4: 1.4.231219000

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 21H2 (22000)

IDE

Visual Studio 2022

Additional context

All 1.4. SDK versions are affected.

@DarranRowe
Copy link

Do you have this problem if you run the application outside of Visual Studio?

Try disabling the in app toolbar.

Screenshot 2024-01-25 222509

Screenshot 2024-01-25 222528

I remember that an issue was introduced with 1.4 where the in app toolbar would cause a crash if multiple Xaml hosts were created on the same thread. I also don't remember seeing that this has been fixed either.

@TomPMoleman
Copy link
Author

@DarranRowe Thanks a bunch for the hint, that indeed was the root cause of the issue!
I've spent a lot of time trying to figure out what I've been doing wrong in the code ... and the solution was that simple after all. ;)
(Still It would be nice if the issue will be resolved sometime in the future, to avoid anyone else investing the same time-consuming debugging effort in vain.)

@bpulliam bpulliam transferred this issue from microsoft/WindowsAppSDK Feb 1, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 1, 2024
Copy link

github-actions bot commented Feb 1, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@bpulliam bpulliam added team-Markup Issue for the Markup team area-Windowing and removed needs-triage Issue needs to be triaged by the area owners labels Feb 1, 2024
@llongley llongley closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2024
@llongley llongley added the closed-Duplicate Described behavior is already captured by another issue. label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windowing closed-Duplicate Described behavior is already captured by another issue. team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

4 participants