Skip to content

Application not crashing if a resource string is incorrect in XAML #20018

Description

@asi-evin

Description

if there is an error with a resource string in XAML, the app will run fine while debugging. However, when you try to run the app without the debugger, it will crash.

Ideally, the application should not compile or at least crash in debug; it's VERY frusterating to try and find the error without the debugger.

Recording.2024-01-19.145412.compressed.mp4

I've noticed this issue on "StaticResource" strings, "Translation" strings and other custom Provider extension strings. There could be other XAML issues that compile and run successfully in debug, but it's difficult to ascertain.

This COULD be related to Hot Reload, I haven't tried without it. I also have only tested Android Emulator, Physcal Android Device, and Physical iOS Device (both remote and local).

Steps to Reproduce

  1. Create a new MAUI project

  2. Add a BackgroundColor to the button, or some other element using a Static Resource that does not exist (e.g.
    <Button BackgroundColor="{StaticResource blooper}"/><!-- static resource that does not exist -->)

  3. Run the Project in Debug

Expected Result: App should crash or not compile

Actual Result: App runs as if everything is hunky-dory

Further issues: App crashes when run without the debugger

Link to public reproduction project repository

No link required, can be replicated with a fresh project very easily.

Version with bug

8.0.6

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

Windows properly throws an exception during runtime, and will even tell you the position in xaml of the error. If possible, maintain windows as a viable platform, even if your app is mobile only.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorsmigration-compatibilityXamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convertplatform/androidplatform/ioss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions