.net - 仅在部署的PresentationFramework 中发生XmlParseException

标签 .net wpf xaml .net-3.5

当我将 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/

相关文章:

xaml - 在 Windows Phone 8 中创建日历控件

c# - WPF - 当网格开始切割元素时使元素消失

.net - 在 VB.Net 中使用 Enter 键的 Tab 键功能

.net - 安装 Visual Studio 2015 后 Fakes 停止工作

c# - 带Docker的Asp.Net Core-包含重复的 'Content'项目

c# - 如何从 HttpClientHandler.CookieContainer 获取 cookie

c# - 有关如何教程(WPF/Entity Framework/ObservableCollections)的问题

c# - 使用 Telerik 组件正确部署应用程序

c# - WPF 控件模板和数据模板

xaml - 有没有比在 XAML 中使用 ObservableCollection 进行快速绑定(bind)更好的方法?