title: How to throw a deserialized exception?
body: <p>I'm serializing a <strong>Exception</strong> at the server with <strong>JsonConvert.SerializeObject</strong> and then encoding to a <strong>byte[]</strong> and deserializing in the client using <strong>JsonConvert.DeserializeObject</strong>. Everything works fine so far... The problem is when I throw the <strong>Exception</strong> the stacktrace being replaced, let me demostrate:</p>
  <pre><code>public void HandleException(RpcException exp)
  {
      // Get the exception byte[]
      string exceptionString = exp.Trailer.GetBytes(&quot;exception-bin&quot;);
      
      // Deserialize the exception
      Exception exception = JsonConvert.DeserializeObject&lt;Exception&gt;(exceptionString, new 
      JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All });
      
      // Log the Exception: The stacktrace is correct. Ex.: at ServerMethod()
      Console.WriteLine(exception);
      
      // Throw the same Exception: The stacktrace is changed. Ex.: at HandleException()
      ExceptionDispatchInfo.Capture(exception).Throw();
  }
  </code></pre>