This is in WPF (C#).
I am trying to find what object is throwing a NullReferenceException when I call the ShowDialog() method in a Window object. The code is similar to this:
MyWindow myWindow = new MyWindow();
//Some properties of myWindows are set here
try
{
myWindow.ShowDialog();
}
catch (Exception) //In here I catch a NullReferenceException
{
}
Is there a way to find what's causing the exception? I placed a Breakpoint in the very beginning of the 'Window_Loaded' Event Handler in the MyWindow class but it just doesn't trigger.
Go to Debugging > Exceptions and tick the "Thrown" checkbox for the Common Language Runtime Exceptions (or more specifically if you wish, the NullReferenceException deeper down in the treeview)
Then run, and the debugger will catch the exception on the line where it is thrown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With