Problems finding which process throws ‘Unexpected exception’

Jan 8 2020 3:25 AM
Hi!
 
Happy new year!
My name is Bjorn Arne Dybvik.
I am currently working on an assignment that consists of finding out what is causing the following error:
'Unexpected exception occured in a worker thread'
I have worked a lot on it and have managed to "catch" the error in the method'
 
private void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args)
{
var aggException = args.Exception.Flatten();
foreach (var exception in aggException.InnerExceptions)
{
LogErrorMessage($"Aggregate exception occured in a worker thread {sender.ToString()} ", exception);
}
Exception e = args.Exception;
LogErrorMessage("Unexpected exception occured in a worker thread", e);
}
 
But I have no clue how to find out where the error is coming from (stacktrace is empty).
 
Does anyone know how to find out what is causing the error?
 
Best regards
Bjorn Arne Dybvik

Answers (3)