title: .net Core Newtonsoft.Json had 'Exception has been thrown by the target of an invocation' error
body: <p>I am developing on .net core 3.1 platform.</p>
  <p>I use log4net for cross cutting concerns logging.
  When I take any error from any service, It will convert to json object then write to log file.</p>
  <p>I use .NET STANDARD library 2.1, this is code bellow</p>
  <pre><code>    var logEvent = new SerializableLogEvent(loggingEvent);
      var json = JsonConvert.SerializeObject(logEvent, Formatting.Indented); // problem is this line
      writer.WriteLine(json);
  </code></pre>
  <p>this SerializableLogEvent.cs</p>
  <pre><code>[Serializable]
  public class SerializableLogEvent
  {
      private LoggingEvent _loggingEvent;
  
      public SerializableLogEvent(LoggingEvent loggingEvent)
      {
          _loggingEvent = loggingEvent;
      }
  
      public object Message =&gt; _loggingEvent.MessageObject;
  }
  </code></pre>
  <p>Why have it error ? System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'</p>
  <pre><code>  System.Reflection.TargetInvocationException
        HResult=0x80131604
        İleti=Exception has been thrown by the target of an invocation.
        Kaynak=System.Private.CoreLib
        StackTrace:
         at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
         at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
         at Newtonsoft.Json.Serialization.JsonContract.&lt;&gt;c__DisplayClass57_0.&lt;CreateSerializationCallback&gt;b__0(Object o, StreamingContext context)
         at Newtonsoft.Json.Serialization.JsonContract.InvokeOnSerializing(Object o, StreamingContext context)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.OnSerializing(JsonWriter writer, JsonContract contract, Object value)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
         at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
         at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
         at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
         at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
         at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, Formatting formatting, JsonSerializerSettings settings)
         at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Formatting formatting, JsonSerializerSettings settings)
         at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Formatting formatting)
         at Core.CrossCuttingConcerns.Logging.Log4Net.Layouts.JsonLayout.Format(TextWriter writer, LoggingEvent loggingEvent) in ...\Core\CrossCuttingConcerns\Logging\Log4Net\Layouts\JsonLayout.cs:line 21
         at log4net.Appender.AppenderSkeleton.RenderLoggingEvent(TextWriter writer, LoggingEvent loggingEvent)
         at log4net.Appender.TextWriterAppender.Append(LoggingEvent loggingEvent)
         at log4net.Appender.FileAppender.Append(LoggingEvent loggingEvent)
         at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent)
      
      
      
      PlatformNotSupportedException: This instance contains state that cannot be serialized and deserialized on this platform.
  </code></pre>