运行WPF应用程序时出错

应用程序在它生成的计算机上正常工作,但当我将它复制到另一个,相同的操作系统时,它崩溃并显示此错误:

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框架或其他东西)时,通常会出现这种错误,但我确保我安装了相同(或更高)版本的.NET框架并且再次无法正常工作。 我查看了应用程序运行的操作系统中已安装的组件,我可以看到Visual Studio 2010附带了许多已安装的程序,我不知道这个应用程序需要哪一个才能运行,我真的没有时间尝试所有这些。 如果有人遇到过类似的问题,请提前给我一些想法。

您可以检查以下步骤以捕获有关exception的更多详细信息: SO问题

我遇到过同样的问题,我已经解决了这个问题。 这是由于缺少某些环境DLL,尝试安装Visual C ++ Redistributable http://www.microsoft.com/en-us/download/details.aspx?id=30679 ,然后运行您的应用程序。

要获取有关exception的更多信息,请将此方法添加到App.xaml.cs

 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: