我有一個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