title: how come BinaryFormatter can serialize an Action<> but Json.net cannot
body: <p>Trying to serialize/deserialize an Action&lt;>.</p>
  
  <p>Try #1 naive by me</p>
  
  <pre><code>JsonConvert.SerializeObject(myAction);
  ...
  JsonConvert.Deserialize&lt;Action&gt;(json);
  </code></pre>
  
  <p>Deserialize fails saying it cannot serialize Action.</p>
  
  <p>Try #2</p>
  
  <pre><code>JsonConvert.DeserializeObject&lt;Action&gt;(ctx.SerializedJob, new JsonSerializerSettings {ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor });
  </code></pre>
  
  <p>Same(ish) failure.</p>
  
  <p>Try # 3
  Then I found <a href="http://mikehadlow.blogspot.com/2011/04/serializing-continuations.html" rel="nofollow noreferrer">http://mikehadlow.blogspot.com/2011/04/serializing-continuations.html</a></p>
  
  <p>This uses BinaryFormatter. I dropped this in (base64 encoding the binary to a string). Worked perfectly first time.</p>
  
  <p>Try #4</p>
  
  <p>I then found</p>
  
  <p><a href="https://github.com/DevrexLabs/Modules.JsonNetFormatter" rel="nofollow noreferrer">https://github.com/DevrexLabs/Modules.JsonNetFormatter</a></p>
  
  <p>Which is an IFormatter module for json.net. Wired that in, same failure - cannot deserialize.</p>
  
  <p>So how come BinaryFormatter can do it but Json.net cannot?</p>
  
  <p>EDIT:</p>
  
  <p>The general reply is - "thats the most stupid thing to want to do". Let me show what I am trying to do</p>
  
  <pre><code>MyJobSystem.AddJob(ctx=&gt;
  {
     // code to do
     // ......
  }, DateTime.UtcNow + TimeSpan.FromDays(2));
  </code></pre>
  
  <p>Ie - execute this lambda in 2 days time.</p>
  
  <p>This works fine for me. Using BinaryFormatter. I was curious about why one serializing infrastructure could do it but the other could not. They both seem to have the same rules about what can and cannot be processed </p>