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

Crash when referencing resource dictionary with styles in WinUI 3 Preview 2 #3371

Closed
marcelwgn opened this issue Oct 5, 2020 · 9 comments
Closed
Labels
area-Resources bug Something isn't working Crash whenever user reports a crash or app freeze product-winui3 WinUI 3 issues

Comments

@marcelwgn
Copy link
Collaborator

marcelwgn commented Oct 5, 2020

Describe the bug

Run the attached project. The app just crashes, opening the exception times out.

image

WinUI3 LibraryCrash.zip

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Create library with two files: Controls.xaml and MyControl.xaml
  2. Reference MyControl.xaml in Controls.xaml as resource dictionary
  3. Reference library/Controls.xaml from a WinUI 3 UWP app
  4. Start app and observe crash.

Expected behavior

The app shouldn't crash.
Screenshots

Version Info

NuGet package version:

WinUI 3 Preview 2

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (20226) Yes
May 2020 Update (19041)
November 2019 Update (18363)
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
Xbox
Surface Hub
IoT

Additional context

This app works in UWP with WinUI 2.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 5, 2020
@chrisglein
Copy link
Member

@chingucoding It sounds like you suspect this has to do with specific resource dictionary references. Do you know when this started to reproduce for you? (as in which bit of markup triggered it). Do you have the full stack trace?

@chrisglein chrisglein added needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Oct 19, 2020
@marcelwgn
Copy link
Collaborator Author

marcelwgn commented Oct 19, 2020

Just ran the app again and now I am able to view the exception message (not sure why now):

Failed to assign to property 'Microsoft.UI.Xaml.ResourceDictionary.Source' because the type 'Windows.Foundation.String' cannot be assigned to the type 'Windows.Foundation.Uri'. [Line: 10 Position: 37]

This error message sounds familiar, is this a know bug or did I make a mistake here?

The crash happens when I am trying to reference the resource dictionary. Commenting out the resource dictionary reference in the "Library1/Controls.xaml" file "fixes" the issue, however it does not include the resource dictionary in the merged dictionary.

Here is the stacktrace (albeit not a very helpful one):

>	App1.exe!App1.App.InitializeComponent.AnonymousMethod__5_0(sender = {App1.App}, e = {Microsoft.UI.Xaml.UnhandledExceptionEventArgs}) Line 53	C#
 	[Native to Managed Transition]	
 	Microsoft.ui.xaml.dll!DirectUI::CFTMEventSource<ABI::Microsoft::UI::Xaml::IUnhandledExceptionEventHandler,ABI::Microsoft::UI::Xaml::IApplication,ABI::Microsoft::UI::Xaml::IUnhandledExceptionEventArgs>::Raise(pSource=0x000001914d95bdd8, pArgs=0x000001914d9efec0) Line 319	C++
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::RaiseUnhandledExceptionEvent(hrToReport=0x802b000a, hstrMessage=0x0000019168f41e30, pfHandled=0x0000007b1247f500) Line 845	C++
 	Microsoft.ui.xaml.dll!DirectUI::ErrorHelper::RaiseUnhandledExceptionEvent(hrToReport=0x802b000a, strMessage={...}, pfHandled=0x0000007b1247f500) Line 287	C++
 	Microsoft.ui.xaml.dll!DirectUI::ErrorHelper::ProcessUnhandledError(errorInfo={...}, fSkipFailFastIfNoErrorContext=1, pfHandled=0x0000007b1247f500) Line 550	C++
 	Microsoft.ui.xaml.dll!DirectUI::FinalUnhandledErrorDetectedRegistration::OnFinalUnhandledErrorDetected(pSender=0x0000007b1247f6a8, pArgs) Line 903	C++
 	twinapi.appcore.dll!00007ffdaad4ccb4()	Unknown
 	twinapi.appcore.dll!00007ffdaad4cd14()	Unknown
 	twinapi.appcore.dll!00007ffdaad3ac6d()	Unknown
 	twinapi.appcore.dll!00007ffdaacc9cbd()	Unknown
 	twinapi.appcore.dll!00007ffdaacc9c2d()	Unknown
 	twinapi.appcore.dll!00007ffdaacc9b99()	Unknown
 	twinapi.appcore.dll!00007ffdaacca9a7()	Unknown
 	combase.dll!00007ffdb3d63a74()	Unknown
 	Microsoft.ui.xaml.dll!DirectUI::ErrorHelper::ReportUnhandledError(hrError=0x802b000a) Line 473	C++
 	Microsoft.ui.xaml.dll!DirectUI::DXamlCore::EnsureCoreApplicationInitialized() Line 552	C++
 	Microsoft.ui.xaml.dll!DirectUI::FrameworkView::Initialize(pCoreApplicationView=0x000001914bcd7d80) Line 45	C++
 	twinapi.appcore.dll!00007ffdaacac177()	Unknown
 	twinapi.appcore.dll!00007ffdaac9b8ec()	Unknown
 	twinapi.appcore.dll!00007ffdaacd3d3a()	Unknown
 	SHCore.dll!00007ffdb3ef819e()	Unknown
 	kernel32.dll!00007ffdb3774b2e()	Unknown
 	ntdll.dll!00007ffdb42e778b()	Unknown



@ghost ghost added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Oct 19, 2020
@chrisglein
Copy link
Member

Sorry for the gap in response, @chingucoding. I did check with someone to see if this was expected to be up and working on WinUI3 and it is, although there could be bugs. If you're still hitting this their recommendation was as follows:

Best course of action would be to upgrade your repro app (the report indicates that it’s a UWP app, so it’s as simple as upgrading the installed WinUI nuget package to the latest from the release/preview3 branch) and see if it still repros (and if it does, get a more useful callstack than the one that gets spit out if one doesn’t break in until the unhandled exception).

As in try this on preview 3 and get the callstack at the point of failure, not in the unhandled state.

@chrisglein chrisglein added needs-author-feedback Asked author to supply more information. and removed needs-triage Issue needs to be triaged by the area owners labels Dec 11, 2020
@marcelwgn
Copy link
Collaborator Author

Unfortunately, this still repros with preview 3. The issue is that the app crashes almost immediately; MainPage.InitializeComponent does not even get called. So beside the unhandled exception stack trace, there isn't much I can provide here I'm afraid.

@ghost ghost added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Dec 11, 2020
@chrisglein chrisglein added appModel-UWP Exclusive to WinUI 2 UWP apps bug Something isn't working has-repro-project area-Resources and removed needs-triage Issue needs to be triaged by the area owners labels Aug 23, 2021
@marcelwgn
Copy link
Collaborator Author

marcelwgn commented Nov 27, 2021

This issue also repros with WinUI 3 Desktop in WASDK 1.0. Using the ms-appx:///[libraryname]/[path-to-file] syntax instead of the path inside the library is a suitable workaround (for me at least).

@krschau krschau removed has-repro-project appModel-UWP Exclusive to WinUI 2 UWP apps labels Jun 13, 2022
@bpulliam bpulliam added the Crash whenever user reports a crash or app freeze label Oct 13, 2022
@pellea
Copy link

pellea commented Dec 7, 2022

This issue also repros with WinUI 3 Desktop in WASDK 1.0. Using the ms-appx:///[libraryname]/[path-to-file] syntax instead of the path inside the library is a suitable workaround (for me at least).

Unfortunatly, for me, this workaround isn't working.
I had to copy the style into the main application ...

@sam-wheat
Copy link

Same problem 2.5 years later. Same project configuration, same error msg.

Using lib name does not resolve the issue:

  <ResourceDictionary Source="ms-appx:///MyLib/Themes/DimensionButton.xaml" />

dotnet 6

@evelynwu-msft
Copy link
Contributor

evelynwu-msft commented Jun 9, 2023

@chingucoding I know it's been several years since you opened this issue, but could you try the repro again with the latest WinAppSDK 1.3 release and see if it still crashes? I recreated your repro app as a WinUI Desktop project (since we no longer support WinUI in UWP) and was unable to trigger the crash myself. I'm open to the possibility that I made a mistake somewhere along the way but we did make a change in ResourceDictionary.Source's implementation as part of WinAppSDK 1.1 to address an unrelated issue so I'm hoping that has also resolved the crash you were seeing.

@marcelwgn
Copy link
Collaborator Author

Thanks for getting back to this @evelynwu-msft! This doesn't seem to repro anymore using WASDK 1.1, closing this issue as it is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Resources bug Something isn't working Crash whenever user reports a crash or app freeze product-winui3 WinUI 3 issues
Projects
None yet
Development

No branches or pull requests

8 participants