From 42484cf41de2f0a7848f2e8484774c8f8f7fb664 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Mon, 20 Dec 2021 16:50:42 +0800 Subject: [PATCH] Fix issue#4775 EventSourceException single event payload too large. --- .../src/Internals/TraceCore.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/System.Private.ServiceModel/src/Internals/TraceCore.cs b/src/System.Private.ServiceModel/src/Internals/TraceCore.cs index dc7906e6ab4..6eb8d350368 100644 --- a/src/System.Private.ServiceModel/src/Internals/TraceCore.cs +++ b/src/System.Private.ServiceModel/src/Internals/TraceCore.cs @@ -15,7 +15,7 @@ namespace System.Runtime internal partial class TraceCore { - + private const int MaxExceptionStringLength = 28 * 1024; static System.Resources.ResourceManager resourceManager; static System.Globalization.CultureInfo resourceCulture; @@ -74,7 +74,7 @@ internal static bool HandledExceptionIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void HandledException(EtwDiagnosticTrace trace, string param0, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.HandledException(param0, serializedException); } @@ -110,7 +110,7 @@ internal static bool ThrowingExceptionIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void ThrowingException(EtwDiagnosticTrace trace, string param0, string param1, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.ThrowingException(param0, param1, serializedException); } @@ -133,7 +133,7 @@ internal static bool UnhandledExceptionIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void UnhandledException(EtwDiagnosticTrace trace, string param0, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.UnhandledException(param0, serializedException); } @@ -261,7 +261,7 @@ internal static bool HandledExceptionWarningIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void HandledExceptionWarning(EtwDiagnosticTrace trace, string param0, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.HandledExceptionWarning(param0, serializedException); } @@ -369,7 +369,7 @@ internal static bool HandledExceptionErrorIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void HandledExceptionError(EtwDiagnosticTrace trace, string param0, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.HandledExceptionError(param0, serializedException); } @@ -392,7 +392,7 @@ internal static bool HandledExceptionVerboseIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void HandledExceptionVerbose(EtwDiagnosticTrace trace, string param0, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.HandledExceptionVerbose(param0, serializedException); } @@ -415,7 +415,7 @@ internal static bool EtwUnhandledExceptionIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void EtwUnhandledException(EtwDiagnosticTrace trace, string param0, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.EtwUnhandledException(param0, serializedException); } @@ -439,7 +439,7 @@ internal static bool ThrowingEtwExceptionIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void ThrowingEtwException(EtwDiagnosticTrace trace, string param0, string param1, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.ThrowingEtwException(param0, param1, serializedException); } @@ -463,7 +463,7 @@ internal static bool ThrowingEtwExceptionVerboseIsEnabled(EtwDiagnosticTrace tra /// Exception associated with the event internal static void ThrowingEtwExceptionVerbose(EtwDiagnosticTrace trace, string param0, string param1, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.ThrowingEtwExceptionVerbose(param0, param1, serializedException); } @@ -487,7 +487,7 @@ internal static bool ThrowingExceptionVerboseIsEnabled(EtwDiagnosticTrace trace) /// Exception associated with the event internal static void ThrowingExceptionVerbose(EtwDiagnosticTrace trace, string param0, string param1, System.Exception exception) { - string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); + string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, MaxExceptionStringLength); WcfEventSource.Instance.ThrowingExceptionVerbose(param0, param1, serializedException); } }