title: Rest transfer non serializable objects
body: <p>Is there a way to send a non serializable object via Rest ?
  I have a request class where some properies can be serialized, but not all.</p>
  
  <p>The class inherits a other class from a SDK (see below 'IWorkflowContext'). This class is protected and can not be serialized - but needs to be transfered. I tried to use JSON, where the non serialization of the SDK object is an issue, when I try to serialize it binary I get a serializer exception </p>
  
  <blockquote>
    <p>"Request for the permission of type
    'System.Security.Permissions.SecurityPermission, mscorlib,
    Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    failed."</p>
  </blockquote>
  
  <p>My request &amp; serialization looks like this for binary : </p>
  
  <pre><code>byte[] bytes;
  IFormatter formatter = new BinaryFormatter();
  using (MemoryStream s = new MemoryStream())
  {
      formatter.Serialize(s, userRequest);
      bytes = s.ToArray();
  }
  stream.Write(bytes, 0, bytes.Length);
  </code></pre>
  
  <p>And here the Json Serialization</p>
  
  <pre><code>DataContractJsonSerializer ser = new DataContractJsonSerializer(userRequest.GetType());
  ser.WriteObject(stream, userRequest);
  </code></pre>
  
  <p>Or another Json serializers (results in the same non serialization problem)</p>
  
  <pre><code>string json = JsonConvert.SerializeObject(userRequest);
  byte[] buffer = Encoding.UTF8.GetBytes(json);
  stream.Write(bytes, 0, bytes.Length);
  </code></pre>
  
  <p>For reference is here my class (modified for binary serialization - for Json I had for each property a Datamember flag.</p>
  
  <pre><code> [Serializable()]
      public class AzureRequest
      {
          public string _orgaName = string.Empty;
          public string _connectionString = string.Empty;
  
          public IWorkflowContext _contextWorkflow = null;
          public string _webhookOperation = string.Empty;
  
          /// &lt;summary&gt;
          /// The Connectionrequest describes a schema to connect to a CRM.
          /// e.g. "Url=http://OrgName.crm.dynamics.com/OrgName;AuthType=Office365;Username=UserName@OrgName.onmicrosoft.com;Password=Password";
          /// &lt;/summary&gt;
           public string ConnectionString
          {
              get
              {
                  return _connectionString;
              }
              set
              {
                  _connectionString = value;
              }
          }
  
          /// &lt;summary&gt;
          /// The Organization Name of the CRM to contact
          /// &lt;/summary&gt;
          public string OrgaName
          {
              get
              {
                  return _orgaName;
              }
              set
              {
                  _orgaName = value;
              }
          }
  
          /// &lt;summary&gt;
          /// Is the running Context for the Worklfow instance
          /// &lt;/summary&gt;
          public IWorkflowContext ContextWorkflow
          {
              get
              {
                  return _contextWorkflow;
              }
              set
              {
                  _contextWorkflow = value;
              }
          }
  
          /// &lt;summary&gt;
          /// The Operation, the Webhook should perform
          /// &lt;/summary&gt;
          public string WebhookOperation
          {
              get
              {
                  return _webhookOperation;
              }
              set
              {
                  _webhookOperation = value;
              }
          }
      }
  </code></pre>