I've written a WCF webservice that takes XML files and stores them into the database. Everything worked fine under 'low load' but under high load I'm getting some unexpected behavior and thusfar I haven't been able to pinpoint what exactly the problem is. Does anybody have a suggestion?
This is the exception I'm seeing in the logs 'sometimes' - like 25 times out of 10 000:
Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Objects.ObjectStateManager.DetectConflicts(IList`1 entries)
at System.Data.Objects.ObjectStateManager.DetectChanges()
at System.Data.Entity.Internal.InternalContext.GetStateEntry(Object entity)
at System.Data.Entity.DbContext.Entry(Object entity)
... rest of my stacktrace
I see this happen every once-in-a-while and I'm currently looking into whether this has to do with concurrency (some other thread maybe working on the same entity). Can someone maybe give me some pointers as to where to look for?
NullReferenceException Occurs when You try to use a reference variable who's value is Nothing/null.
I can't tell what the problem is, But i believe its with the threads. Since its working fine for small number of users. It might have used multiple threads for improving performance when the load increased. When threads executes asynchronously, there is a greater chance for having this issue.!!
The Solution i can offer is to custom specify the threads, and synchronise the Objects. Probably it will solve the Issue.