Your comment
You are right . gotta an inner exception object says " at MyApp.ViewModels.CreateViewModel.d__61.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.b__0(Object state) " Message : Object reference not set to an instance of an object.
just shows that somewhere, you're invoking an async method which is not awaited: when a method returns a task, always await it.
Your inner exception should have an inner exception (i.e. $exception.InnerException.InnerException whiches stacktrace will show you the location of your NullReferenceException)
UnhandledException event is invoked when an exception in your code has not been handled by your code, and the app doesnt know how to handle it.
By default, it makes your app crash.
However, you can prevent your app from crashing in those cases. See this to know more about it.
To fix your issue "the clean way", you will have to find the place where your code is not awaited, and fix it. ie somewhere you will find:
myObject.DoSomethingAsync(); // DoSomethingAsync() returns a task.
Change it :
try
{
await myObject.DoSomethingAsync(); // DoSomethingAsync() returns a task.
}catch(Exception ex)
{
// display error message or whatever
}
[edit] this will handle the error, but what you really want to fix is the cause of your nullref exception. I dont have that much clues, but it looks like a thread concurrency issue.