Skip to content

Missing StaticResource should throw exception also in Debug #15602

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

Closed
danardelean opened this issue Jun 13, 2023 · 11 comments
Closed

Missing StaticResource should throw exception also in Debug #15602

danardelean opened this issue Jun 13, 2023 · 11 comments
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios platform/macos macOS / Mac Catalyst platform/windows s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@danardelean
Copy link

Description

The current version of MAUI does not throw an exception in debug if a StaticResource is missing. The behaviour is inconsistent with Xamarin.Forms but the bigger problem comes in Release mode where the application does crash if the StaticResource is missing but the error message is not "readable" in Release
The missing StaticResource should throw exception also in Debug in order to be able to catch this error before compiling in Release and not understanding what is going on

Steps to Reproduce

Use the attached repository or any MAUI application that uses a StaticResource that is missing and build it in Debug and Release.

In Debug you won't have errors while running the application in Release the application will throw but with almost no way to know what generated the problem

Link to public reproduction project repository

https://github.com/danardelean/MauiStaticResourceProblem

Version with bug

7.0.49

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

All

Did you find any workaround?

No

Relevant log output

No response

@danardelean danardelean added the t/bug Something isn't working label Jun 13, 2023
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Jun 13, 2023
@PureWeen
Copy link
Member

@StephaneDelcroix thoughts?

@PureWeen PureWeen added this to the Backlog milestone Jun 13, 2023
@ghost
Copy link

ghost commented Jun 13, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@StephaneDelcroix
Copy link
Contributor

the exception might be swallowed by the instrumentation

@StephaneDelcroix StephaneDelcroix self-assigned this Jun 14, 2023
@StephaneDelcroix
Copy link
Contributor

both throw in the context of unit tests, so my gut feel of instrumentation swallowing the exception might be somehow right. checking

@StephaneDelcroix
Copy link
Contributor

@chabiss thoughts ?

@chabiss
Copy link
Contributor

chabiss commented Jun 14, 2023

Static Analysis in the language service might be a possibility adding @mgoertz-msft

@danardelean
Copy link
Author

Any feedback on this issue?

@czmirek
Copy link

czmirek commented Aug 28, 2023

I found this issue today by accidentaly removing a StaticResource that was referenced by all my buttons. The issue did not produce any warning on Debug when compiling and it built during release also without warnings. Buttons still worked in Debug but in Release all buttons stopped working (not even with a crash, the buttons simply don't do anything at all).

There is a possible workaround: replace {StaticResource MyResource} with {x:Static app:MyResources.MyResource}. If you try to compile with a reference to a static property that does not exist you get a compile error. But you have to then move your resources to a C# code which is not ideal for everyone I guess.

@homeyf
Copy link

homeyf commented Jan 19, 2024

Verified this issue with Visual Studio Enterprise 17.9.0 Preview 3. Can repro on Windows platforms with sample project.
https://github.com/danardelean/MauiStaticResourceProblem

@homeyf homeyf added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Jan 19, 2024
@Dhivya-SF4094
Copy link
Contributor

The issue could not be reproduced in .NET MAUI version 9.0.60 on all platforms

Image

@vishnumenon2684 vishnumenon2684 added partner/syncfusion Issues / PR's with Syncfusion collaboration s/try-latest-version Please try to reproduce the potential issue on the latest public version labels May 15, 2025
Copy link
Contributor

Hi @@danardelean. 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.

@dotnet-policy-service dotnet-policy-service bot removed this from the Backlog milestone May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios platform/macos macOS / Mac Catalyst platform/windows s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants