WPF C# Tutorial

  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="WpfApplication1.App"
  StartupUri="MainWindow.xaml" 
  DispatcherUnhandledException="App_DispatcherUnhandledException" />
//File:Window.xaml.cs
using System; 
using System.Text;
using System.Windows;
using System.Windows.Threading; 
namespace WpfApplication1
{
    public partial class App : Application
    {
        void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            Console.WriteLine(e.Exception.InnerException.Message);
            Console.WriteLine(e.Exception.Message);
            Console.WriteLine(e.Dispatcher.Thread.ManagedThreadId);
         
            e.Handled = true;
        }
    }
}