I've got an error that I cannot seem to track down when my page is trying to load a list of files from the server.
I pulled this code out of a TFS shelf-set, and it was running when it was saved.
I have tried breaking down the line where the error occurs (commented out in the code shown) and added extra checks just in case the data happen to have null
entries.
Here is a snippet of it:
if (roadmap != null)
{
List<Guid> taskList = lstRoadmapTaskMapping.Select(o => o.TaskGuid).ToList();
var list = SessionManager.CurrentContext.TaskDecisionDetails.Where(x => x.Task != null && x.Task.TaskGuid != null && taskList.Contains(x.Task.TaskGuid));
var lstTaskDecisionDetail = new List<TaskDecisionDetail>(list);
//List<TaskDecisionDetail> lstTaskDecisionDetail = SessionManager.CurrentContext.TaskDecisionDetails.Where(o => taskList.Contains(o.Task.TaskGuid)).ToList();
lstOfTasks = lstTaskDecisionDetail.Select(o => o.TaskToStart).ToList();
lstOfTasks.AddRange(lstTaskDecisionDetail.Select(o => o.AssociatedTaskGuid ?? Guid.Empty).ToList());
lstOfTasks.AddRange(SessionManager.Current.CurrentContext.TaskDecisionDetailRoutes.Where(o => taskList.Contains(o.TaskDecisionDetail.Task.TaskGuid)).Select(o => o.NATaskGuid).ToList());
List<Guid> roadmapMappingGuid = lstRoadmapTaskMapping.Where(o => lstOfTasks.Contains(o.TaskGuid)).Select(o => o.RoadmapTaskMappingGuid).ToList();
treeHL.JSProperties["cp_NoDeleteIDs"] = string.Join(",", roadmapMappingGuid);
}
The exception is thrown at the green highlighted line in the screenshot below:
The error message is this common one:
Object reference not set to an instance of an object.
The question below goes fully into that error message.
What does "Object reference not set to an instance of an object" mean?
That is what got me to break the single line (commented out at the moment) into 2 lines, hoping that would solve my error.
The StackTrace is pointing to the Entity framework:
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
What else could be null
in the expression?
How can I go about debugging this error?
I am also curious about what it means whenever the debugger stops on a green breakpoint instead of a yellow breakpoint.