Skip to content

Object reference not set to an instance of an object exception in NotifySynchronizationContextOfCompletion() #40463

@lhak

Description

@lhak

I am not sure if this is the right place to post this issue but I tried on stackoverflow before and did not get any respone.

Description

I have an application running on .net core 3.1 that reads frames from a camera and displays them on the screen (uses one big XAML island in a windows forms window). After running it for a few hours it often crashes with an "Object reference not set to an instance of an object" exception that I can catch in the AppDomain UnhandledException event handler. I can get the following stack trace:

System.Runtime.CompilerServices.AsyncVoidMethodBuilder.NotifySynchronizationContextOfCompletion()
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Unfortunately, all my efforts to find the cause of this exception have been unsuccessful. None of the code that I run on the thread pool (one periodic timer and some code to process the image frame) seems to be active when it occurs.

Configuration

Windows 10, version 2004
x64
.net core SDK 3.1.400

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Threading.TasksquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions