C# 运行WPF应用程序时出错
该应用程序在其所在的计算机上运行良好,但当我将其复制到另一台相同的操作系统时,它崩溃,并显示以下错误:C# 运行WPF应用程序时出错,c#,.net,wpf,deployment,C#,.net,Wpf,Deployment,该应用程序在其所在的计算机上运行良好,但当我将其复制到另一台相同的操作系统时,它崩溃,并显示以下错误: Problem signature: Problem Event Name: CLR20r3 Problem Signature 01: vpn2.exe Problem Signature 02: 1.0.0.0 Problem Signature 03: 4f615c78 Problem Signature 04: mscorlib Problem Signatur
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: vpn2.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 4f615c78
Problem Signature 04: mscorlib
Problem Signature 05: 4.0.0.0
Problem Signature 06: 4ba1da6f
Problem Signature 07: 3dab
Problem Signature 08: ce
Problem Signature 09: System.Windows.Markup.XamlParse
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
现在,我知道这类错误通常在缺少组件时出现,比如.NET framework或其他东西,但我确保安装了相同(或更高)版本的.NET framework,但它仍然无法工作。我查看了应用程序运行的操作系统中已安装的组件,我可以看到Visual Studio 2010附带了许多已安装的程序,我不知道该应用程序需要哪一个,我真的没有时间全部试用。如果有人遇到过类似的问题,请提前告诉我一些想法,谢谢。您可以检查以下步骤以了解有关异常的更多详细信息:我遇到了相同的问题,我已经解决了这个问题。
这是由于缺少一些环境DLL,尝试安装VisualC++ +可再分发,然后运行你的应用程序。< P>以获得更多关于异常的信息,将此方法添加到你的应用程序。
public partial class App : Application {
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) {
Exception ex = e.Exception;
Exception ex_inner = ex.InnerException;
string msg = ex.Message + "\n\n" + ex.StackTrace + "\n\n" +
"Inner Exception:\n" + ex_inner.Message + "\n\n" + ex_inner.StackTrace;
MessageBox.Show(msg, "Application Halted!", MessageBoxButton.OK);
e.Handled = true;
Application.Current.Shutdown();
}
}
并将DispatcherUnhandledException=“App_DispatcherUnhandledException”发送到您的App.xaml:
<Application x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
DispatcherUnhandledException="App_DispatcherUnhandledException">
<Application.Resources>
</Application.Resources>
</Application>