0

Relatively new to working with .net but learning a lot while working with a developer at work who at times can be stubborn. Recently the asp.net web form we are developing has periodically started crashing such that every time a link is clicked that retrieves an object (an in process form that the user had previously filled out) the user gets the following application error: "Sequence contains more than one element."

All the sources I looked at online suggested that this was an InvalidOperationException thrown by the Single method and could be avoided by (a) eliminating the source of duplicate elements or (b) using the First method instead of the Single method.

The developer told me that I had no idea what I was talking about and that this was a caching error that could only be solved via an IIS reset. Since this has been happening periodically I'm a bit concerned that doing the IIS reset doesn't address the underlying issue that creates the exception. Any one have any ideas? Is my developer right to say that an IIS reset is the best way to address this?

Thanks!

  • 1
    Even if you can't include the exact code including some code would be useful in helping people answer your question – konkked Feb 27 '15 at 02:59
  • This is not an IIS issue, this is definitely a code issue and has something to do with `LINQ`, Post the code which is causing this issue or search for `Single` extension method in your code. – Rahul Singh Feb 27 '15 at 04:19

1 Answers1

0

According to me your developer might have used LINQ. If he used single() or SingleOrDefault() or First() , tell him to replace those method with FirstorDefault() method.