title: Why is my application stops working after 300 records?
body: <p>I have an application that returns a list of data, <code>List &lt;t&gt; </code>through a web method that worked fine from the beginning, until the number of returned records passed 300, try using try catch to see where in the code it will be generates the error and only when the method finishes executing it generates the following exception.</p>
  <p><code>'System.InvalidOperationException' in System.Web.Extensions.dll</code></p>
  <p>This is the code:</p>
  <pre><code>[WebMethod]
  public static string cargarRegNacViv(string dato, string opc, string fechaMin, string fechaMax)
  {
      List&lt;CRRegNacViv&gt; RegNacVivs = new List&lt;CRRegNacViv&gt;();
      if (opc == &quot;Código RUAF&quot;)
      {
          CRCodRuaf CodRuaf = DAOCRCodRuaf.getCodRuaf(dato);
          RegNacVivs = DAOCRRegNacViv.getRegNacViv(Convert.ToString(CodRuaf.IntOIdCRCodRuaf), opc);
      }
      else
          RegNacVivs = DAOCRRegNacViv.getRegNacVivs(dato, opc);
  
      List&lt;double&gt; codRuaf = new List&lt;double&gt;();
      foreach (CRRegNacViv NacViv in RegNacVivs)
      {
          codRuaf.Add(DAOCRCodRuaf.getCodRuafId(Convert.ToString(NacViv.IntCRCodRuaf)).DoubleCRcodRuaf);
      }
  
      Object[] datos = { RegNacVivs, codRuaf };
      return JsonConvert.SerializeObject(datos);
  }
  
  </code></pre>
  <p>la consola muestra el siguiente mensaje cuando el metodo termina
  <a href="https://i.stack.imgur.com/Xma5c.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  <p>other methods</p>
  <pre><code>
  public static List&lt;CRRegNacViv&gt; getRegNacViv(string dato, string opc)
          {
              List&lt;CRRegNacViv&gt; RegNacVivs = new List&lt;CRRegNacViv&gt;();
              //RegNacVivs = null;
              SqlCommand command;
              SqlDataReader reader;
              Conexion conexion = new Conexion();
              string tabla = &quot;&quot;;
  
              switch (opc)
              {
                  case &quot;Documento Madre&quot;: tabla = &quot;IdMadre&quot;; break;
                  case &quot;Nombre Madre&quot;: tabla = &quot;NomMadre&quot;; break;
                  case &quot;Tipo Parto&quot;: tabla = &quot;TipNac&quot;; break;
                  case &quot;Código RUAF&quot;: tabla = &quot;OidCRCodRuaf&quot;; break;
                  case &quot;Documento Médico&quot;: tabla = &quot;GNCodUsu&quot;; break;
              }
  
              try
              {
                  command = new SqlCommand(&quot;select * from CRNacidoVivo WHERE &quot; + tabla + &quot;= '&quot; + dato + &quot;'  &quot;, conexion.OpenConnection());
                  //command.Parameters.AddWithValue(&quot;@tabla&quot;, tabla);
                  command.ExecuteNonQuery();
                  reader = command.ExecuteReader();
                  
                  while (reader.Read())
                  {
                      CRRegNacViv regNacViv = new CRRegNacViv();
                      regNacViv.DoubleIdMadre = Convert.ToDouble(reader[&quot;IdMadre&quot;].ToString());
                      regNacViv.StrNomMadre = reader[&quot;NomMadre&quot;].ToString();
                      regNacViv.StrTipNac = reader[&quot;TipNac&quot;].ToString();
                      regNacViv.DateFecNac = Convert.ToDateTime(reader[&quot;FecNac&quot;].ToString());
                      regNacViv.IntCRCodRuaf = Convert.ToInt32(reader[&quot;OIdCRCodRuaf&quot;].ToString());
                      regNacViv.IntEdGesNac = Convert.ToInt32(reader[&quot;EdadGes&quot;].ToString());
                      regNacViv.DoubleGNCodUsu = Convert.ToDouble(reader[&quot;GNCodUsu&quot;].ToString());
                      regNacViv.StrNomDoc = reader[&quot;NomDoc&quot;].ToString();
                      regNacViv.IntPesoRn = Convert.ToInt32(reader[&quot;PesoRN&quot;].ToString());
                      regNacViv.FloatTallaRN = float.Parse(reader[&quot;TallaRN&quot;].ToString());
                      regNacViv.StrSexo = reader[&quot;Sexo&quot;].ToString();
                      RegNacVivs.Add(regNacViv);
                  }
                   
                  
  
              }
              catch (Exception)
              {
                 
              }
              finally
              {
                  conexion.CloseConnection();
              }
              return RegNacVivs;
          }
  
  
  public static CRCodRuaf getCodRuafId(string OIdCRCodRuaf)
          {
              CRCodRuaf codRuaf = new CRCodRuaf();
              SqlCommand command;
              SqlDataReader reader;
              Conexion conexion = new Conexion();
  
              try
              {
                  command = new SqlCommand(&quot;select * from CRCodRuaf where OIdCRCodRuaf = @CRcodRuaf &quot;, conexion.OpenConnection());
                  command.Parameters.AddWithValue(&quot;@CRcodRuaf&quot;, OIdCRCodRuaf);
                  reader = command.ExecuteReader();
                  if (reader.Read())
                  {
                      codRuaf = new CRCodRuaf
                      {
                          IntOIdCRCodRuaf = Convert.ToInt32(reader[&quot;OIdCRCodRuaf&quot;]),
                          DateFecCod = Convert.ToDateTime(reader[&quot;FecCod&quot;]),
                          StrIncidencia = reader[&quot;Incidencia&quot;].ToString(),
                          IsEstado = Convert.ToBoolean(reader[&quot;Estado&quot;]),
                          StrTipCodigo = reader[&quot;TipCodigo&quot;].ToString(),
                          DoubleGNCodUsu = Convert.ToDouble(reader[&quot;GNCodUsu&quot;]),
                          DoubleCRcodRuaf = Convert.ToDouble(reader[&quot;CRcodRuaf&quot;]),
  
                      };
                  }
              }
              catch (Exception wi)
              {
  
                  
              }
              finally
              {
                  conexion.CloseConnection();
              }
  
  
  
              return codRuaf;
          }
  
  </code></pre>