在項目 App.xaml 文件下 => Application 節點=> 添加 DispatcherUnhandledException="Application_DispatcherUnhandledException" 屬性
在App.xaml.cs下添加方法
void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
var comException = e.Exception as System.Runtime.InteropServices.COMException;
if (comException != null && comException.ErrorCode == -2147221040)
e.Handled = true;
}
本來只是想自己做下筆記,所以寫的不是特別清楚。看閱讀量比較大特意重新編輯,希望能幫到大家。
.
