我有一个WPF应用程序崩溃,一旦我把它放到没有安装开发环境的机器上 - 如果这是一个骗局,我欢迎关闭,但我的搜索fu没有找到一个等效的题。看来我得到一个XamlParseException,但没有比这更有用。我需要得到有用的信息。如何从用户的机器获得有用的WPF .NET错误信息?
通过Windows 7的事件日志去给我这个错误日志:
Fault bucket , type 0
Event Name: CLR20r3
Response: Not available
Cab Id: 0
Problem signature:
P1: MyApp.exe
P2: 1.0.0.0
P3: 4b88323d
P4: PresentationFramework
P5: 3.0.0.0
P6: 4a174fbc
P7: 624f
P8: e1
P9: System.Windows.Markup.XamlParse
P10:
Attached files:
C:\Users\Mark\AppData\Local\Temp\WER7DC.tmp.WERInternalMetadata.xml
These files may be available here:
C:\Users\Mark\AppData\Local\Microsoft\Windows\WER\ReportArchive
\AppCrash_generatortestbed_4fa7dff09a9e893eb675f488392571ced4ac8_04ef1100
Analysis symbol:
Rechecking for solution: 0
Report Id: cd55060c-271f-11df-b6ff-001e52eefb8e
Report Status: 1
我检查这些目录,而第一不存在,而第二个包含WER文件,只是列出了加载dll。
我可以在我的测试机器上安装一个开发环境,但它不能成为一台测试机器,我又回到了原点。我在安装开发环境时没有得到这个错误,所以我不知道如何获得详细而有用的错误消息。
编辑:建筑关闭@Alastair皮茨评论的下方,这里是我如何填写异常处理:
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) {
Exception theException = e.Exception;
string theErrorPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\GeneratorTestbedError.txt";
using (System.IO.TextWriter theTextWriter = new System.IO.StreamWriter(theErrorPath, true)){
DateTime theNow = DateTime.Now;
theTextWriter.WriteLine("The error time: " + theNow.ToShortDateString() + " " + theNow.ToShortTimeString());
while (theException != null) {
theTextWriter.WriteLine("Exception: " + theException.ToString());
theException = theException.InnerException;
}
}
MessageBox.Show("The program crashed. A stack trace can be found at:\n" + theErrorPath);
e.Handled = true;
Application.Current.Shutdown();
}
希望,我会得到什么,我需要这样。谢谢您的帮助!
如果ITIS一个XamlParseError,似乎会发生这样的错误之前,我可以使用任何代码,只需在应用程序窗口的绘制。在用户代码被调用之前有没有办法跟踪这个异常?或者我错了XamlParseErrors? – mmr