I'm loading Values from Session to Entity Object but is giving error. ( An exception of type 'System.NullReferenceException' occurred in Project_Portal.dll but was not handled in user code.Additional information: Object reference not set to an instance of an object. ). How can i resolve this Problem??? Here is my Code...
Here my form upload Files are converted to binary to save in database.So, i applied foreach loop for multiple files & load them one by one in List object.
else if (ext.ToString().ToLower() == ".doc" || ext.ToString().ToLower() ==
".pdf")
{
using (Stream fs = files[i].InputStream)
{
using (BinaryReader br = new BinaryReader(fs))
{
bytes = br.ReadBytes((Int32)fs.Length);
}
}
ProjectDataObject.Data = bytes;
ProjectDataObject.Nature = 3;
}
ProjectDataObject.EmailID =
HttpContext.Current.Session["EmailID"].ToString();
ProjectDataObject.StudentProjectID
=Convert.ToInt32(HttpContext.Current.Session["StudentProjectID"]);
DataList.Add(ProjectDataObject);
foreach (ProjectDataEntity item in DataList)
{
item.EmailID = ProjectDataObject.EmailID;
item.StudentProjectID =
ProjectDataObject.StudentProjectID;
item.Nature = ProjectDataObject.Nature;
item.Data = ProjectDataObject.Data;
}
When i load EmailID from HttpContext.Current.Session["EmailID"].ToString() to ProjectDataObject.EmailID it generates the error shown above.