dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

Version 17.10.0 will not parse one of my XAML pages in a maui app #23012

Open vsfeedback opened 5 months ago

vsfeedback commented 5 months ago

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version] [regression] [worked-in:17.10.0] Maui app was working fine. Pushed it to repository then updated VS to version 17.10.0. Reloaded the app and now the main xaml page will not compile. I get a very cryptic error message pointing me to a line that is NOT in error.

Severity Code Description Project File Line Suppression State Details Error (active) Input string was not in a correct format. MOPCOnlineDirectory (net8.0-android), MOPCOnlineDirectory (net8.0-ios), MOPCOnlineDirectory (net8.0-maccatalyst), MOPCOnlineDirectory (net8.0-windows10.0.19041) D:\Projects\MOPCOnlineDirectory\MOPCOnlineDirectory\View\MainPage.xaml 1

The line it points to is the xml declaration (the first line in the file)!! I tried to diagnose by commenting out sections of the xml. If I comment out the majority of the page, it builds. As I started adding sections back in it continued to build, until I got to the primary part of the page. Then, regardless of which subsection I uncommented, I got that message.

I ran my code through an online valdiator and it pronounced it "valid".

I have attached the xaml file.


Original Comments

Randy Kreisel on 5/25/2024, 00:19 PM:

(private comment, text removed)

Feedback Bot on 5/26/2024, 07:24 PM:

(private comment, text removed)


Original Solutions

(no solutions)

github-actions[bot] commented 5 months ago

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 and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

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

rkreisel commented 3 months ago

This post contains a solution.

I was eventually forced to install WASM tools for a different project. Upon returning to the MAUI project I started getting this error again. (without upgrading VS 2022 to the latest version).

I then upgraded VS 2022 to version 17.10 (which did not help) I was left with diagnosing the problem by commenting out code until VS could parse the xaml file. After several hours of changing sections of xaml, I eventually happened upon the solution.

Note: The only indicator of the fact that there was a problem was that Intellisense does not offer the properties you expect to see from the object in question. But if you know the property name and type it in it does not throw an error saying it cannot find it. I will admit, I am new to XAML, so I rely a LOT on intellisense to highlight problems. And this one does not get flagged.

Solution: It was a problem with the DataType property of a DataTemplate.

I had: x:DataType=“{x:Type model:Person}”

but it needed to be: x:DataType=“model:Person”

Oddly, earlier versions of VS didn’t have a problem with this (now) invalid code. (and worked at run time)

The worst problem in this whole issue is that the error message was totally unhelpful! It did not point to the error. So, somewhere along the way MS “improved” the parser to catch the datatype definition problem (thanks) but failed to determine how to accurately report the error to the user.

The second worst problem is that everyone here kept saying I was reporting a duplicate problem, but the references to the supposed duplicates contained no helpful information. (Indicating that this was note really a duplicate.)

jfversluis commented 1 month ago

Sorry you had a rough time with this @rkreisel just to be very clear. Is this resolved now? Thanks!

rkreisel commented 1 month ago

This turned out to be an error in my XAML that was not triggered in earlier VS versions. I found it by commenting out everything and slowly re-adding code. (Tedious but effective).

dotnet-policy-service[bot] commented 17 hours ago

Hi @vsfeedback. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

mattleibow commented 17 hours ago

Adding try latest version for now so we can auto-close this in a few days.

@StephaneDelcroix did the allowed XAML syntax for this type of thing change/become more strict?

rkreisel commented 17 hours ago

I would love to help by re-trying in the preview version, but, as noted above, I found and corrected the error in my XAML, so it works now. Sadly, I don't have the time to restore the (very) old version from source control and test your fix. But, thank you for your diligence. You are a credit to the community.