C# 错误';不支持指定的方法';。获取调用堆栈
我的应用程序在客户端pc上出现错误“不支持指定的方法”。我不知道问题出在哪里。他没有安装Visual Studio,因此无法调试C# 错误';不支持指定的方法';。获取调用堆栈,c#,wpf,C#,Wpf,我的应用程序在客户端pc上出现错误“不支持指定的方法”。我不知道问题出在哪里。他没有安装Visual Studio,因此无法调试 如果我在应用程序中编写一些调试代码并给他新的exe,有没有办法在WPF中获得调用堆栈?您可以订阅dispatchernhandledexception以捕获应用程序级别未处理的异常并记录异常的堆栈跟踪 App.xaml.cs中的DispatcherUnhandledException示例 public App() { this.DispatcherUn
如果我在应用程序中编写一些调试代码并给他新的exe,有没有办法在WPF中获得调用堆栈?您可以订阅
dispatchernhandledexception
以捕获应用程序级别未处理的异常并记录异常的堆栈跟踪
App.xaml.cs中的DispatcherUnhandledException
示例
public App() {
this.DispatcherUnhandledException += OnDispatcherUnhandledException;
}
void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) {
string errorMessage = string.Format("An unhandled exception occurred: {0}", e.Exception.Message);
MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
e.Handled = true;
}
在大图中,您可以在以下位置捕获异常:
您可以在不同级别捕获未处理的异常:
AppDomain。来自AppDomain中所有线程的未处理异常
Dispatcher.来自单个特定UI Dispatcher的未处理异常
线
TaskScheduler.unobservedtaskeexception
来自每个AppDomain
使用任务计划程序进行异步操作的。你应该
考虑需要在什么级别捕获未处理的异常。决定#2和#3取决于您是否使用了多个WPF线程 最简单的方法可能是使用
ex.ToString()
获取整个异常详细信息。这将显示调用堆栈和任何内部异常详细信息。