title: JSON.stringify throws error "A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'. "
body: <p>On the client side an object 'selectedMeter' is build in JavaScript. This object is send to the server with an ajax call and passed to the mvc controller.</p>
  
  <pre><code>$.ajax({
     url: 'SaveManualMeter',
     type: "POST",
     cache: false,
     contentType: "application/json; charset=utf-8",
     data: **JSON.stringify({ clientId: selectedClientId, manualMeter: selectedMeter** }),
     complete: function () {
  </code></pre>
  
  <p>When <strong>tested locally, it works, however when the site is published, it throws an error</strong>  A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'. </p>
  
  <blockquote>
    <ul>
    <li>[InvalidOperationException: A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'.]   </li>
    <li>System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +1856</li>
    <li>System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember) +266</li>
    <li>System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) +668</li>
    </ul>
  </blockquote>
  
  <p>The <strong>controller</strong> look like this </p>
  
  <pre><code>public ActionResult
      SaveManualMeter(string clientId, ManualMeter manualMeter)
  </code></pre>
  
  <p>Does someone knows what the problem is?</p>
  
  <p>The <strong>structure</strong> of manualmeter looks like</p>
  
  <pre><code> [JsonObject(IsReference = false)]
      public class ManualMeter
      {
          public int Id { get; set; }      
          public string Ean { get; set; }        
          public PeriodType Period { get; set; }        
          public string TagTable { get; set; }
          public string TagTableId { get; set; }
          public int Overflow { get; set; }
          public string TZ { get; set; }
  
          public DataLogger DataLogger { get; set; }
  
          public Tag Tag { get; set; }
  
          public List&lt;ManualMeterAction&gt; ManualMeterActions { get; set; }       
      }
  
   public class ManualMeterAction
      {
          public int Id { get; set; }
          public ManualMeterActionType Type { get; set; }
  
          //navigation properties
          public int ManualMeterId { get; set; }
          public int UserId { get; set; }
      }
  </code></pre>
  
  <p>raw json object that is posted seems ok</p>
  
  <pre><code>{"clientId":"11","manualMeter":{"Tag":{"Name":"22","Unit":"Unknown","TagType":"0","Content":"1"},"Id":0,"Ean":"","ManualMeterActions":[],"Period":"0","Overflow":"22","TZ":"Europe/Brussels"}}
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/GJc7m.jpg" rel="nofollow">raw json image</a></p>