The complete details of the exception is:
System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type Com.SchoolCity.ReportCards.ReportCardLibrary.Data. StudentScoresDO was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
at System.Xml.Serialization.XmlSerializationWriter.Wr iteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write4_StudentDO(String n, String ns, StudentDO o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write7_ArrayOfStudentDO(Object o)
at Microsoft.Xml.Serialization.GeneratedAssembly.List OfStudentDOSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(T extWriter textWriter, Object o)
at System.Web.Services.Protocols.XmlReturnWriter.Writ e(HttpResponse response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.W riteReturns(Object[] returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.Wr iteReturns(Object[] returnValues)
at System.Web.Services.Protocols.WebServiceHandler.In voke()
And the code behind is as follows:
- public List<StudentDO> GetStudentsForReportCard(int iTeacherKey, int iLocationKey, string strGrade, string strSchoolYear, int iClassKey)
-
{
-
List<StudentDO> lstStudent = new List<StudentDO>();
-
-
DataSet dsStudentsDetails = GetStudents(iTeacherKey, iLocationKey, strGrade, strSchoolYear, iClassKey);
-
if (!CommonUtility.IsValidObject(dsStudentsDetails)) return null;
-
foreach (DataRow dr in dsStudentsDetails.Tables[0].Rows)
-
{
-
StudentDO objStudent = new StudentDO();
-
objStudent.StudentKey = Convert.ToInt32(dr["Student_Key"]);
-
objStudent.StudentName = dr["Student_Name"].ToString();
-
objStudent.DistrictName = dr["District_Name"].ToString();
-
objStudent.SchoolName = dr["School_Name"].ToString();
-
objStudent.IsStudentActive = (dr["Is_Active"]).Equals(0) ? false : true;
-
objStudent.IsSpecialED = (dr["Special_Education"]).Equals(0) ? false : true;
-
objStudent.IsEnglishLearner = (dr["English_Learner"]).Equals(0) ? false : true;
-
DatasetUtility obj = new DatasetUtility();
-
SerializableDictionary<string, StudentScoresDO> ldStudentScoresStatus = new SerializableDictionary<string, StudentScoresDO>();
-
DataTable dtScoresStatus = obj.FilterTable(string.Concat("Student_Key ='", dr["Student_Key"].ToString(), "'"), dsStudentsDetails.Tables[1]);
-
foreach (DataRow drGradingPeriod in dtScoresStatus.Rows)
-
{
-
-
if (!ldStudentScoresStatus.ContainsKey(drGradingPeriod["Grading_Period_Name"].ToString()))
-
{
-
StudentScoresDO objStudentScores = new StudentScoresDO();
-
objStudentScores.IsScoreExists = Convert.ToBoolean(drGradingPeriod["Is_Score_Exists"]);
-
objStudentScores.IsScoringCompleted = Convert.ToBoolean(drGradingPeriod["Is_Scoring_Completed"]);
-
objStudentScores.IsScoresEnteredByAnotherTeacher = (Convert.ToBoolean(drGradingPeriod["Entered_By_AnotherTeacher"])).Equals(1) ? true : false;
-
objStudentScores.TeacherKey = (objStudentScores.IsScoresEnteredByAnotherTeacher == true) ? Convert.ToInt32(drGradingPeriod["Teacher_Key"]) : 0;
-
objStudentScores.TeacherName = (objStudentScores.IsScoresEnteredByAnotherTeacher == true) ? drGradingPeriod["Teacher_Name"].ToString() : string.Empty;
-
ldStudentScoresStatus.Add(drGradingPeriod["Grading_Period_Name"].ToString(), objStudentScores);
-
}
-
}
-
object[][] objStudentScoresStatus = new object[ldStudentScoresStatus.Count][];
-
int iIndex = 0;
-
foreach (string strKey in ldStudentScoresStatus.Keys)
-
{
-
objStudentScoresStatus[iIndex] = new object[] { strKey, ((StudentScoresDO)ldStudentScoresStatus[strKey]) };
-
iIndex++;
-
}
-
objStudent.StudentScores = objStudentScoresStatus;
-
lstStudent.Add(objStudent);
-
}
-
return lstStudent;
-
}
-
While getting the value of the StudentScores property from StudentDO this exception is raised:
- public Object[][] StudentScores
-
{
-
get { return this._objStudentScores; }--Here
-
set { this._objStudentScores = value; }
-
}
The version of .net is 3.5