Today the debugger always reports an exception:
The value cannot be null.
Parameter name: Source
Exception Details: System.ArgumentNullException: The value cannot be null.
Parameter name: source
The breakpoint was found to be this code error, the exception that occurs is usually a parameter in the method is empty, and my method does not have a parameter named source Ah, and later found that processors is NULL, the call to the Select method will of course error.
processors = taskwfservice.identifynextworkflowprocessors (Currentuserid, currenttaskworkflow.reporttaskid); var Processors New taskworkflowprocessor {Processor = Item}). ToList ();
But according to our usual experience, a null object, when calling its method, should throw NullReferenceException An instance exception that does not set the object to an object ? For example, we call the ToString () method
var // thrown a NullReferenceException
In fact, that's the problem. In the Select () method, press F12 on the Select to view the definition
Public Static Ienumerable<tresult> Select<tsource, tresult> (Thissource, Func<tsource, TResult > selector);
This is a System.Linq extension method (not before. NET 3.5), except for Select there are many common, such as Where, any, by, SelectMany, take, etc.
This method internally determines that the passed-in parameter, source null, throws a ArgumentNullException.
I think if the this parameter in the extension method is NULL, is it more appropriate to throw a NullReferenceException? At least it's easier to get rid of mistakes.
The value cannot be null. Parameter name: source