当我将 WPF 应用程序部署到另一个用户的计算机时,出现以下异常:
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
但是,当我打开 WPF 应用程序时,它运行良好。应用程序在启动时崩溃并显示此消息。我已经仔细检查以确保他们的计算机上安装了 .NET 3.5 SP1,并且还验证了他们可以运行原型(prototype) WPF 应用程序。有没有好的方法来解决此类错误?
谢谢!
最佳答案
您可以设置一些代码来捕获未处理的异常:
在 App.Xaml 中
<Application
...
DispatcherUnhandledException="App_DispatcherUnhandledException" />
在App.Xaml.cs中
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// Add code to output the exception details to a message box/event log/log file, etc.
// Be sure to include details about any inner exceptions
// Prevent default unhandled exception processing
e.Handled = true;
}
如果这不能揭示确切的问题,它至少可以为您提供足够的信息来开始。
关于.net - 仅在部署的PresentationFramework 中发生XmlParseException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1981348/