I am getting a null reference exception that I can't pin down.
By process of elimination using a variety of assumptions I've narrowed it down to a single variable, a linq iteration variable, like so:
var process = (from p in context.Processes where p.ProcessID == processID select p).FirstOrDefault();
Is it possible that
p variable is null? If so why would SPMetal/the DataContext have given me a null list item?
Here is a list of all assumptions made, which have narrowed down my list of dereferences to this single instance:
- Assume stack trace is accurate (no need to look further into called methods)
- Assume types cannot be null
- Assume constructors cannot return null
- Assume linq queries do not return null (https://stackoverflow.com/questions/1191919/what-does-linq-return-when-the-results-are-empty)
- Assume no internal method changes my variables to null (used VS's "find all references" feature to confirm)
- Assume UserControls instantiated in the ascx cannot be null
- Assume execution did not reach a certain point (where a list item would have been created)
- Assume IssueRegister list was not removed or renamed since the page was last loaded, and that if it was, SPMetal generated code would have thrown an error instead of returning null
SPContext.Current.Webdoes not return null (for a browser request to a page)