diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index dad30c70eb21..1b715a61074e 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -568,7 +568,7 @@ void ApplyLiteralProperties() void AttachUnhandledExceptionHandler() { - writer.Append($"#if DEBUG"); + writer.Append($"#if DEBUG && !DISABLE_GENERATED_UNHANDLED_EXCEPTION_HANDLER"); writer.AppendLine(); writer.AppendLineIndented($"UnhandledException += (s, e) =>"); writer.AppendLineIndented("{");