.Net Client - Object reference not set to an instance of an object
John R
Posted on
Dec 04 2013
Hey,
The raygun client is throwing this error occasionally. The exception being passed seems valid.
Version: 1.0.8.0
Stack Trace: at Mindscape.Raygun4Net.Messages.RaygunRequestMessage.ToDictionary(NameValueCollection nameValueCollection, Boolean truncateValues) in e:\Users\Jason\Documents\GitHub\raygun4net\Mindscape.Raygun4Net\Messages\RaygunRequestMessage.cs:line 55 at Mindscape.Raygun4Net.Messages.RaygunRequestMessage..ctor(HttpContext context) in e:\Users\Jason\Documents\GitHub\raygun4net\Mindscape.Raygun4Net\Messages\RaygunRequestMessage.cs:line 21 at Mindscape.Raygun4Net.RaygunClient.BuildMessage(Exception exception) in e:\Users\Jason\Documents\GitHub\raygun4net\Mindscape.Raygun4Net\RaygunClient.cs:line 1140 at RevenueLoan.Utils.ErrorHandler.HandleError(Exception exc) in C:\Lexine\trunk\Apps\RevenueLoanUtil\ErrorHandler.cs:line 170
John R
Posted on
Dec 04 2013
I think I found out what my issue was. I believe this is a threading issue on my end. "RaygunClient.Send" is not a tread safe method. Seems like maybe it could be? Anyway sorry for the false alarm.
John-Daniel Trask
Raygun
Posted on
Dec 04 2013
Hello John
I have not been able to reproduce an error like this in multi threading scenarios. If you could describe the threading issue you had so that we can reproduce the problem, this would help us improve the quality of the provider. In any case, it's good to hear that you found the likely cause of the issue.
-Jason
John R
Posted on
Dec 05 2013
Hi Jason,
Thanks for looking into this for me. I don't have a great handle on what was going on. Someone on my team wrote some bad code that would occasionally throw several exceptions in a very short period. Our error handling code keeps a static instance of the Raygun client object and during these periods of very fast exception handling I would see the above object reference exception thrown from the Raygun object. Just guessing that this was a treading issue, I put a lock around the Raygun.send method call and the object reference exceptions went away. This may have been coincidental or caused by some side effect of the lock statement.
I'm not really sure it's the Raygun.send method's responsibility to be thread safe. Most instance methods in .net are not thread safe. I was just suggesting that it might nice if the method was thread safe due to the fact that error handlers tend to be singletons.
If you have already built the method to be thread safe, I will look around for what else could have causing the issue.
John