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

XAML Parsing Exception Messages are not Useful #3163

Closed
jtbrower opened this issue Aug 19, 2020 · 4 comments
Closed

XAML Parsing Exception Messages are not Useful #3163

jtbrower opened this issue Aug 19, 2020 · 4 comments
Labels
area-ErrorHandling Issues related to error reporting and debugging area-Parser product-winui3 WinUI 3 issues team-Markup Issue for the Markup team

Comments

@jtbrower
Copy link

I was asked to open an issue by @stevenbrix when I mentioned this over on the August 19th community call announcement. Note that in my case, I was creating WinUI Desktop applications.

I find the XAML Parsing exception messages to be near useless when trying to correct parsing mistakes. I have an extensive background in WPF application development so its not as if I am new to using XAML.

While trying to port a small subset of XAML libraries over to WinUI, not a single exception message has been useful in helping me resolve my problems. Although I have not been logging a tally of those, the following example is typical of what I have encountered.

Example of Error Messages for a simple XAML Error

Take for example the mistake that I made when defining a XAML StaticResource for the type "Double". I thought that I could add a using for System and then define the resource with sys:Double. As you can see from the exception message below, it would be extremely difficult to know what type of XAML parsing error had occurred. It doesn't even point to the assembly that actually caused the error let alone have a warm hint of what the problem was. When issues like this occur, I have to start backing out each and every block of XAML until the code runs without exception. Since it takes much longer to launch a packaged application, its a very tedious, time consuming and error prone process.

Writing raw XAML is error prone, but when porting hundreds of XAML files from WPF, errors are unavoidable. My mistake was using sys:Double instead of x:Double.

xmlns:sys="using:System"
...
<sys:Double x:Key="DoubleKey">.5</sys:Double>
Microsoft.UI.Xaml.dll!7A6F17CF: (caller: 7A471CB9) Exception(1) tid(85cc) 80004005 Unspecified error
Exception thrown at 0x76119862 in Oceanside.VirtualKeyboard.Sample.App.exe: Microsoft C++ exception: wil::ResultException at memory location 0x00D79C40.
Exception thrown at 0x76119862 in Oceanside.VirtualKeyboard.Sample.App.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Microsoft.UI.Xaml.dll!7A6F2F43: (caller: 7A4CE21A) ReturnHr(1) tid(85cc) 80004005 Unspecified error
    Msg:[Microsoft.UI.Xaml.dll!7A6F17CF: (caller: 7A471CB9) Exception(1) tid(85cc) 80004005 Unspecified error
] 
Exception thrown: 'Microsoft.UI.Xaml.Markup.XamlParseException' in winrt.runtime.dll
WinRT information: Could not create a new view because the main window has not yet been created
An exception of type 'Microsoft.UI.Xaml.Markup.XamlParseException' occurred in winrt.runtime.dll but was not handled in user code
WinRT information: Could not create a new view because the main window has not yet been created
XAML parsing failed.
@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Aug 19, 2020
@StephenLPeters StephenLPeters added team-Markup Issue for the Markup team product-winui3 WinUI 3 issues labels Aug 19, 2020
@robloo
Copy link
Contributor

robloo commented Aug 20, 2020

Agreed, this has been discussed a few places before as well. I haven't been able to locate the issues to link to though.

@robloo
Copy link
Contributor

robloo commented Aug 21, 2020

Here is the other issue I was thinking of: #2350 and a comment #2861 (comment).

@stevenbrix
Copy link
Contributor

stevenbrix commented Nov 19, 2020

Thanks for the follow up @jtbrower and @robloo, sorry for the slow response. This should be improved in 16.8 and 16.9 Preview 1, where the Microsoft.UI.Xaml.Markup.XamlParseException should be enabled by default.

@robloo thanks for linking those other issues. I know the experience still isn't great, so I'm not going to close this issue out, as we can keep it open to track this.

@stevenbrix stevenbrix removed the needs-triage Issue needs to be triaged by the area owners label Nov 19, 2020
@stevenbrix stevenbrix added this to Freezer in Feature tracking via automation Nov 19, 2020
@evelynwu-msft evelynwu-msft added area-Parser area-ErrorHandling Issues related to error reporting and debugging labels Nov 29, 2022
@bpulliam
Copy link
Contributor

bpulliam commented Dec 7, 2022

Closing as this morphed into #7033.

@bpulliam bpulliam closed this as completed Dec 7, 2022
@ghost ghost removed this from Freezer in Feature tracking Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ErrorHandling Issues related to error reporting and debugging area-Parser product-winui3 WinUI 3 issues team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

7 participants