Skip to content

Conversation

@Vignesh-SF3580
Copy link
Contributor

@Vignesh-SF3580 Vignesh-SF3580 commented Feb 3, 2026

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

When an invalid template name is provided, the app crashes on Android and iOS when relaunching the app.

Root Cause

Inconsistent exception handling in StaticResourceExtension - it returned null when an exception handler was present but threw an exception when debugger is not attached.

Description of Change

Modified StaticResourceExtension.cs and ApplyPropertiesVisitor.cs to always throw exceptions for invalid StaticResource references, regardless of whether an exception handler is present. Previously, the code returned null and allowing the app to continue. The fix ensures consistent behavior by creating the exception once, optionally logging it through the exception handler if available, and then always throwing it.

Tested the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #23903

Screenshots

iOS:

Before Issue Fix After Issue Fix
23903BeforeiOS.mov
23903AfteriOS.mov

Android:

Before Issue Fix After Issue Fix
23903AndroidBefore.mov
23903AndroidAfter.mov

@Vignesh-SF3580 Vignesh-SF3580 added the community ✨ Community Contribution label Feb 3, 2026
@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Feb 3, 2026
@Vignesh-SF3580 Vignesh-SF3580 changed the title [Android, iOS] Fix app relaunch crash caused by invalid StaticResource templates [Android, iOS] Throw exceptions consistently for invalid StaticResource references to prevent relaunch crashes Feb 3, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review February 5, 2026 13:35
Copilot AI review requested due to automatic review settings February 5, 2026 13:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix issue #23903 where apps crash on Android and iOS when relaunching with invalid StaticResource references (e.g., missing ControlTemplate). The proposed solution changes the exception handling behavior to always throw exceptions for invalid StaticResource references, regardless of whether an exception handler is present.

Changes:

  • Modified StaticResourceExtension to create the exception once, optionally log it through the exception handler if present, then always throw it (previously returned null when handler was present)
  • Updated ApplyPropertiesVisitor to always rethrow exceptions after logging them to the exception handler (previously only threw if no handler was present)
  • Added a test to verify that exceptions are thrown even when ExceptionHandler2 is set

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Controls/src/Xaml/MarkupExtensions/StaticResourceExtension.cs Changed to always throw XamlParseException for missing resources after optionally logging to ExceptionHandler2, instead of returning null when handler is present
src/Controls/src/Xaml/ApplyPropertiesVisitor.cs Modified exception handling to always rethrow after invoking exception handler, removing the conditional logic that only threw when no handler was present
src/Controls/tests/DeviceTests/Xaml/StaticResourceTests.cs Added test to verify missing StaticResource throws exception even when ExceptionHandler2 is set

@rmarinho rmarinho added s/agent-reviewed PR was reviewed by AI agent workflow s/agent-review-incomplete AI agent could not complete all phases s/agent-gate-passed AI verified tests catch the bug labels Feb 11, 2026
@dotnet dotnet deleted a comment from rmarinho Feb 12, 2026
@dotnet dotnet deleted a comment from rmarinho Feb 12, 2026
@dotnet dotnet deleted a comment from rmarinho Feb 12, 2026
@dotnet dotnet deleted a comment from rmarinho Feb 12, 2026
@dotnet dotnet deleted a comment from rmarinho Feb 13, 2026
@dotnet dotnet deleted a comment from rmarinho Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-gate-passed AI verified tests catch the bug s/agent-review-incomplete AI agent could not complete all phases s/agent-reviewed PR was reviewed by AI agent workflow s/ai-reproduction-failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening a page with an undefined control template crashes on iOS only when not debugging

2 participants