I have a complex wpf-application, where I am using some third-party components. Occantionally my application crashes in specific windows, and I can't figure out why.
Is there a way to catch an exception for an entire window?
I tried the following, but it did not work.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var window1 = new Window1();
window1.Owner = this;
try
{
window1.Show();
}
catch { }
}
}
And the childwindow:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
int a = 0;
int b = 1 / a; //This will throw an exception
}
}
Any suggestions?