-3
Windows Phone 7 응용 프로그램에서 마지막으로 충돌 (예외)을받을 수있는 방법 내 응용 프로그램에서 C#을 사용하고 있습니다.Windows Phone 7 응용 프로그램에서 마지막으로 충돌을 얻는 방법은 무엇입니까?
Windows Phone 7 응용 프로그램에서 마지막으로 충돌 (예외)을받을 수있는 방법 내 응용 프로그램에서 C#을 사용하고 있습니다.Windows Phone 7 응용 프로그램에서 마지막으로 충돌을 얻는 방법은 무엇입니까?
놀랍지 만 응용 프로그램이 충돌하는 경우가 있습니다. 심지어 내 꺼야! WP7에서 애플 리케이션이 처리되지 않은 예외를 가지고있을 때 그것은 운영체제에 의해 죽게되고 당신 개발자는 현명하지 않을 것입니다. 그러나 당신은 당신의 애플 리케이션이 죽었을 때 알고 싶은 경우, 이상적 왜 여기 here
namespace YourApp
{
public class LittleWatson
{
const string filename = "LittleWatson.txt";
internal static void ReportException(Exception ex, string extra)
{
try
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
SafeDeleteFile(store);
using (TextWriter output = new StreamWriter(store.CreateFile(filename)))
{
output.WriteLine(extra);
output.WriteLine(ex.Message);
output.WriteLine(ex.StackTrace);
}
}
}
catch (Exception)
{
}
}
internal static void CheckForPreviousException()
{
try
{
string contents = null;
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists(filename))
{
using (TextReader reader = new StreamReader(store.OpenFile(filename, FileMode.Open, FileAccess.Read, FileShare.None)))
{
contents = reader.ReadToEnd();
}
SafeDeleteFile(store);
}
}
if (contents != null)
{
if (MessageBox.Show("A problem occurred the last time you ran this application. Would you like to send an email to report it?", "Problem Report", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
EmailComposeTask email = new EmailComposeTask();
email.To = "[email protected]";
email.Subject = "YourAppName auto-generated problem report";
email.Body = contents;
SafeDeleteFile(IsolatedStorageFile.GetUserStoreForApplication()); // line added 1/15/2011
email.Show();
}
}
}
catch (Exception)
{
}
finally
{
SafeDeleteFile(IsolatedStorageFile.GetUserStoreForApplication());
}
}
private static void SafeDeleteFile(IsolatedStorageFile store)
{
try
{
store.DeleteFile(filename);
}
catch (Exception ex)
{
}
}
}
}
에서 일부 코드
참조 어디서든 자신을 기록합니까입니까? 나는 WP7이 데스크톱 버전과 같은 것을 기록한다고 생각하지 않는다. – jAC