title: C# - Failed to convert parameter value from a RuntimeMethodInfo to a String
body: <p>Here is the code:</p>
  
  <pre><code>internal static void UpdateErrorLogTable(string type, string location, string method, Exception _error, string ftpDirectory, string remoteName, string localName)
      {
          try
          {
              using (SqlConnection databaseConnection = GetDatabaseConnection())
              {
                  using (SqlCommand cmd = GetSqlCommand("ins_error_log", databaseConnection))
                  {
                      SqlParameter log_date = cmd.Parameters.Add("@log_date", SqlDbType.DateTime);
                      SqlParameter exception_type = cmd.Parameters.Add("@exception_type", SqlDbType.VarChar);
                      SqlParameter class_name = cmd.Parameters.Add("@class_name", SqlDbType.VarChar);
                      SqlParameter method_name = cmd.Parameters.Add("@method_name", SqlDbType.VarChar);
                      SqlParameter error_msg = cmd.Parameters.Add("@error_msg", SqlDbType.VarChar);
                      SqlParameter stack_trace_msg = cmd.Parameters.Add("@stack_trace_msg", SqlDbType.VarChar);
                      SqlParameter target_site_msg = cmd.Parameters.Add("@target_site_msg", SqlDbType.VarChar);
                      SqlParameter ftp_directory = cmd.Parameters.Add("@ftp_directory", SqlDbType.VarChar);
                      SqlParameter ftp_name = cmd.Parameters.Add("@ftp_name", SqlDbType.VarChar);
                      SqlParameter ftp_path = cmd.Parameters.Add("@ftp_path", SqlDbType.VarChar);
                      SqlParameter inner_exception_msg = cmd.Parameters.Add("@inner_exception_msg", SqlDbType.VarChar);
  
                      log_date.Value = m_todaysDate;
                      exception_type.Value = type;
                      class_name.Value = location;
                      method_name.Value = method;
                      error_msg.Value = _error.Message;
                      stack_trace_msg.Value = _error.StackTrace;
                      target_site_msg.Value = _error.TargetSite;
                      ftp_directory.Value = ftp_directory;
                      ftp_name.Value = remoteName;
                      ftp_path.Value = localName;
                      inner_exception_msg.Value = _error.InnerException;
  
                      cmd.ExecuteNonQuery();
                  }
              }  // using databaseConnection
          } //end of TRY statement
          catch (SqlException e)
          {
              logFile.SendToLog("SqlException", "Logs\\LogsDataAccess.cs", "UpdateErrorLogTable()", e);
          } //end of SqlException CATCH statement
      } //end of method UpdateErrorLogTable
  </code></pre>
  
  <p>The error I get is an InvalidCastException but it happens when attempting to execute</p>
  
  <pre><code>cmd.ExecuteNonQuery();
  </code></pre>
  
  <p>The part I can't figure out is why am I getting an InvalidCastException here and not at one of the points above where I'm assigning values.  I stepped through the code in Debug line-by-line of this and it only gets the error when attempting to execute the code at that one line.  </p>
  
  <p>I performed a Google search for </p>
  
  <blockquote>
    <p>Failed to convert parameter value from a RuntimeMethodInfo to a String</p>
  </blockquote>
  
  <p>but no hits.  So I searched for</p>
  
  <blockquote>
    <p>convert from RuntimeMethodInfo to String</p>
  </blockquote>
  
  <p>and still no luck.  </p>
  
  <p>To help you understand the code a little better, the statement </p>
  
  <pre><code>GetSqlCommand("ins_error_log", databaseConnection)
  </code></pre>
  
  <p>basically goes out and recognizes the info in quotes is a Stored Procedure and not a query string.  </p>
  
  <p>All this code above has been used throughout the application (written by someone else) and all I did was copy it and make the necessary modifications to the stored procedure name, the SQL parameters, and the values inserted.</p>
  
  <p>I appreciate all your help!</p>
  
  <p>*Note: I tried setting the TAG for this question as "RuntimeMethodInfo" but it wouldn't let me because I have less than a 1500 reputation.  Maybe someone else can do it for me or give me the permissions to handle this. </p>