In my REST WCF service I log all exceptions on WCF stack level (IErrorHandler)
Here is my code:
public void PostPositions(List<Position> positions)
{
if (!this.ValidateRequest()) return;
foreach (var position in positions)
{
I get exception:
Object reference not set to an instance of an object.
at Web.Services.MobileService.PostPositions(List`1 positions)
in
C:\CodeWorkspace\ClientServerCode\Web.Services\Rest\MobileService.cs:line
1170 at SyncInvokePostPositions(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
instance, Object[] inputs, Object[]& outputs)
Line 1170 in my code is for if (!this.ValidateRequest()) return;
What does it mean? There is no static methods, I work with instance of a class and this definitely exists. If exception happens inside ValidateRequest() I expect stack trace to show that.
Any pointers?
I would be willing to bet that
positionsis what’s null and thatforeach(var position in positions)is what’s throwing the exception when callingGetEnumerator()on positions.As you might guess, it’d be very easy for the line number calculation to get a bit jumbled here, since the
foreachloop is just syntactic sugar for something like this: