I am seeing an issue whereby our errors are being logged to sentry correctly from some servers, but not correctly on others, from a c# web application, hosted in IIS and using SharpRaven 2.2. This seems to be occuring for CaptureAsync() only, as Capture() is working on all servers. Will try and give what I have tried below and hopefully someone may be able to give a nudge in the right direction.
So on the servers that are seeing the issue we saw the below exception popping up in event viewer. So I added targetFramework=“4.5” in the web.config of the application as suggested here https://goo.gl/YcpVgZ. That stopped the errors appearing, but errors were still not coming through to sentry. Apparently .NET 4.5 provided some additional functionality around asynchronous programming, but my application is set to run 4.5, 4.5 is also installed on the server.
I then started comparing the server roles/features in server manager between the servers that do/dont work and they both seem to match up. I would thinkg it is an environment issue as we have multiple machines internally and externally that do/dont work, I just can’t seem to narrow down what it is. I have tried using ErrorOnCapture to log any internal errors that may be occuring but there is nothing showing up. Any suggestions where to go from here?
(this.ravenClient as RavenClient).ErrorOnCapture = e =>
// Code to log to textfile
Initial Exceptions that were being logged in event viewer below:
An unhandled exception occurred and the process was terminated. Application ID: /LM/W3SVC/3/ROOT/
Process ID: 4832 Exception: System.NullReferenceException Message: Object reference not set to an instance of an object.
StackTrace: at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean setImpersonationContext)
at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state)
at System.Web.LegacyAspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state)
at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)
— End of stack trace from previous location where exception was thrown —
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
Application: w3wp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException at System.Web.ThreadContext.AssociateWithCurrentThread(Boolean)
at System.Web.LegacyAspNetSynchronizationContext.CallCallbackPossiblyUnderLock(System.Threading.SendOrPostCallback, System.Object)
at System.Web.LegacyAspNetSynchronizationContext.CallCallback(System.Threading.SendOrPostCallback, System.Object)
at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback, System.Object, System.Threading.Tasks.Task ByRef)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)