C# .NET - Getting error "Invalid object format name" in crystal report.

Asked By binta prasad on 01-Jun-12 02:00 AM
Earn up to 20 extra points for answering this tough question.
I'm writing a function to change the font color of the data in crystal report.When i'm trying to load crystal report its showing error "Invalid object format name". I don't know what to do? Pls help me.

Code for setting the color dynamically
  private void ReportColorSettings(ReportDocument report)
    {
      try
      {
        DAL.Institute objInstitute = new DAL.Institute();
        DataTable objDataTable = objInstitute.GetReportColor();
        System.Drawing.ColorConverter objConverter = new System.Drawing.ColorConverter();
        section = (Sections)report.ReportDefinition.Sections;
        for (int i = 0; i < section.Count; i++)
        {

          foreach (ReportObject r in section[i].ReportObjects)
          {
            //ObjectFormat oformat;
            FieldFormat fformat;
            if (r.Kind.ToString() == "FieldObject")
            {
              FieldObject f = (FieldObject)r;
              //fformat = f.FieldFormat;
              f.Color = (System.Drawing.Color)objConverter.ConvertFromString("#" + objDataTable.Rows[0]      
[i].ToString());
              
            }


            if (r.Kind.ToString() == "TextObject")
            {
              TextObject t = (TextObject)r;
             
              t.Color = (System.Drawing.Color)objConverter.ConvertFromString("#" + objDataTable.Rows[0][i].ToString()); ;
            }
          }
        }
      }
      catch (Exception ex)
      {
      }
    }