title: A circular reference was detected while serializing an object of type 'System.Reflection
body: <p>I have an asp.net MVC 3 controller action method like this:</p>
  
  <pre><code>public JsonResult GetRecordingRates(int Id)
  {            
      List&lt;DefaultRateChart&gt; defaultRateCharts = new List&lt;DefaultRateChart&gt;();
      using (IDefaultRateChartManager defaultRateChartManager = new ManagerFactory().GetDefaultRateChartManager()) {
         defaultRateCharts = defaultRateChartManager.GetAll().Where(rc =&gt; rc.Currency.Id == Id &amp;&amp; (!rc.NumberPrefix.StartsWith("#") || rc.NumberPrefix.StartsWith("Default")) &amp;&amp; rc.AccountCredit == "Credit").ToList();
      }
      return Json(defaultRateCharts);
  }
  </code></pre>
  
  <p>I want to send this list to jquery ajax success method but I am getting  <strong>500 Internal Server Error</strong></p>
  
  <p>my ajax call is like this:</p>
  
  <pre><code>$.ajax({
  type: "POST",
  dataType: "json",
  url: "/Home/GetRecordingRates",
  data: {
      Id: $("#hdCurrencyId").val()                 
  },
  success: function (data) {
          alert(data);
     }
  }); 
  </code></pre>
  
  <p>In firebug XHR under response tab, it says:</p>
  
  <p>A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'.</p>
  
  <p>[EDIT]</p>
  
  <p>I changed the action method to this:</p>
  
  <pre><code>public JsonResult GetRecordingRates(int Id)
  {
      List&lt;DefaultRateChart&gt; defaultRateCharts = new List&lt;DefaultRateChart&gt;();
      using (IDefaultRateChartManager defaultRateChartManager = new ManagerFactory().GetDefaultRateChartManager())
      {
          defaultRateCharts = defaultRateChartManager.GetAll().Where(rc =&gt; rc.Currency.Id == Id &amp;&amp; (!rc.NumberPrefix.StartsWith("#") || rc.NumberPrefix.StartsWith("Default")) &amp;&amp; rc.AccountCredit == "Credit").ToList();
      }
  
      return this.Json(
          new
          {
              Result = (from obj in defaultRateCharts select new { Id = obj.Id, DialPrefix = obj.NumberPrefix, Rate = obj.PurchaseRates })
          }
          , JsonRequestBehavior.AllowGet
       );
  }
  </code></pre>
  
  <p>and I dont get that error now but how can I parse the collection in ajax success. I changed success to following but it is not adding rows in table.</p>
  
  <pre><code>success: function (data) {
              var row = $('&lt;tr&gt;');
              for(var i = 0; i &lt; data.length; i++) {
                  row.append($('&lt;td&gt;').html(data[i]));
              }   
  
              $('#results').append(row);                                      
              jQuery('#RecordingRates').dialog({ closeOnEscape: false });
              $(".ui-dialog-titlebar").hide();
              $("#RecordingRates").dialog({ dialogClass: 'transparent' });
              $('#RecordingRates').dialog('open');
             }
      }); 
  </code></pre>
  
  <p>In Firebug Net => XHR=> Json, It shows following JSON:</p>
  
  <pre><code>[Object { Id=
  
  1
  
  ,  DialPrefix=
  
  "1"
  
  ,  Rate=
  
  2.6
  
  }, Object { Id=
  
  3
  
  ,  DialPrefix=
  
  "2"
  
  ,  Rate=
  
  2.6
  
  }, Object { Id=
  
  5
  
  ,  DialPrefix=
  
  "7"
  
  ,  Rate=
  
  3.5
  
  }, 3 more...]
  
  
  0
      Object { Id=
  
  1
  
  , DialPrefix=
  
  "1"
  
  , Rate=
  
  2.6
  
  }
  
  1
      Object { Id=
  
  3
  
  , DialPrefix=
  
  "2"
  
  , Rate=
  
  2.6
  
  }
  
  2
      Object { Id=
  
  5
  
  , DialPrefix=
  
  "7"
  
  , Rate=
  
  3.5
  
  }
  
  3
      Object { Id=
  
  7
  
  , DialPrefix=
  
  "8"
  
  , Rate=
  
  6
  
  }
  
  4
      Object { Id=
  
  9
  
  , DialPrefix=
  
  "Default"
  
  , Rate=
  
  5
  
  }
  
  5
      Object { Id=
  
  15
  
  , DialPrefix=
  
  "Subscription"
  
  , Rate=
  
  15
  
  }
  </code></pre>