简体   繁体   中英

UnobservedTaskException - Where did the task come from

In my MVC application, I sometimes get an exception like:

System.Net.WebException: The request was aborted: The request was canceled.
   at System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state)
   at System.Net.Http.HttpClientHandler.StartGettingRequestStream(RequestState state)
   at System.Net.Http.HttpClientHandler.<>c__DisplayClass4.<PrepareAndStartContentUpload>b__0(Task task)
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---

EDIT Here's another kind I'm seeing:

System.Exception: Unhandled Task Error ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
   at System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(Exception error)
   at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---

Here's what I see in the event log, but it's not exactly correlated in time or count.

A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 40. The Windows SChannel error state is 1205.

An TLS 1.2 connection request was received from a remote client application, but none of the cipher suites supported by the client application are supported by the server. The SSL connection request has failed.

/EDIT

Is there a way to identify the source/location of the exception or get any other information about where the exception came from?

EDIT 2 Here's another one I'm seeing. They're all related to OnAsyncHandlerCompletion, but I'm not sure what the source is.

System.Exception: Unhandled Task Error ---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.HttpApplication.get_CurrentModuleContainer()
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(Exception error)
at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---

/EDIT 2

您可以订阅TaskScheduler.UnobservedTaskException事件,并可能获取有关该异常的更多信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM