From 5c28ee7c30623a6c9911061c0d00a3ae12d9421d Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Mon, 4 Nov 2019 17:27:10 +0100 Subject: [PATCH] ObjectHandleSerializer - GetObjectData should be marked as SecurityCritical (#3660) --- src/NLog/Internal/ObjectHandleSerializer.cs | 9 ++++++--- src/NLog/MappedDiagnosticsLogicalContext.cs | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/NLog/Internal/ObjectHandleSerializer.cs b/src/NLog/Internal/ObjectHandleSerializer.cs index ca1c5b7d7c..b9ef449ad5 100644 --- a/src/NLog/Internal/ObjectHandleSerializer.cs +++ b/src/NLog/Internal/ObjectHandleSerializer.cs @@ -65,10 +65,13 @@ protected ObjectHandleSerializer(SerializationInfo info, StreamingContext contex catch (Exception ex) { _wrapped = string.Empty; // Type cannot be resolved in this AppDomain - InternalLogger.Info(ex, "ObjectHandleSerializer failed to deserialize object: {0}", type); + InternalLogger.Debug(ex, "ObjectHandleSerializer failed to deserialize object: {0}", type); } } +#if NET4_5 + [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, SerializationFormatter = true)] +#endif public void GetObjectData(SerializationInfo info, StreamingContext context) { try @@ -95,7 +98,7 @@ public void GetObjectData(SerializationInfo info, StreamingContext context) catch (Exception ex) { // ToString on random object can throw exception - InternalLogger.Info(ex, "ObjectHandleSerializer failed to serialize object: {0}", _wrapped?.GetType()); + InternalLogger.Debug(ex, "ObjectHandleSerializer failed to serialize object: {0}", _wrapped?.GetType()); } } @@ -105,4 +108,4 @@ public object Unwrap() } } #endif -} +} \ No newline at end of file diff --git a/src/NLog/MappedDiagnosticsLogicalContext.cs b/src/NLog/MappedDiagnosticsLogicalContext.cs index 98e2f24c7d..b334946f4e 100644 --- a/src/NLog/MappedDiagnosticsLogicalContext.cs +++ b/src/NLog/MappedDiagnosticsLogicalContext.cs @@ -416,5 +416,4 @@ private static Dictionary GetThreadLocal() } } -#endif - +#endif \ No newline at end of file