Tag: 未处理的exception

用户代码未处理来自Dll get Exception的C#User Definedexception处理

我正在使用动态c#应用程序,它将所有类从我单独创建的Dll文件链接到主应用程序,在这些文件中,当我动态连接我的dll文件时,error handling程序希望通过连接抛出错误,因为它曾经是这是我尝试做的事情 我有一个dll文件,上面有这个编码和类 class clsGlobles { public object dlststus = false; // dtabase file status public clsGlobles() { try { if (dlststus == true) { } else { throw new Exception(“Some important files are missing – Please re-install the application”); //throw this as a error and stop running the program } } catch (Exception ex) […]

在WPF中捕获子线程中的未处理exception

我有一个WPF应用程序,可以旋转多个线程。 我在App.xaml.cs中定义了一个DispatcherUnhandledException事件处理程序,它显示详细的错误消息,每次UI线程遇到exception时都会调用此处理程序。 问题在于子线程:它们未处理的exception永远不会得到处理。 我该怎么做呢? 示例代码: private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { MessageBox.Show(“detailed error message”); } private void Application_Startup(object sender, StartupEventArgs e) { //… //If an Exception is thrown here, it is handled //… Thread[] threads = new Thread[numThreads]; for(int i = 0; i < numThreads; i++) { threads[i] = new Thread(doWork); threads[i].Start(); } } […]