Added fatal exception handler with error dump on desktop.

This commit is contained in:
Lorenz Cuno Klopfenstein 2010-06-20 02:01:04 +02:00
parent 3e7c8a29dd
commit 8fba47cbeb
4 changed files with 46 additions and 8 deletions

View file

@ -6,10 +6,10 @@ using OnTopReplica.Properties;
using VistaControls.Dwm;
using VistaControls.TaskDialog;
namespace OnTopReplica
{
public partial class MainForm : AspectRatioForm
{
namespace OnTopReplica {
public partial class MainForm : AspectRatioForm {
//Visualization status
bool _clickForwarding = false;
@ -33,6 +33,7 @@ namespace OnTopReplica
public MainForm(Point location, Size size)
: this() {
_startOverride = true;
_startLocation = location;
_startSize = size;

View file

@ -49,8 +49,8 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>2.9.4.%2a</ApplicationVersion>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.9.5.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
@ -304,6 +304,16 @@
<IncludeHash>True</IncludeHash>
<FileType>Satellite</FileType>
</PublishFile>
<PublishFile Include="da\OnTopReplica.resources">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Satellite</FileType>
</PublishFile>
<PublishFile Include="it\OnTopReplica.resources">
<Visible>False</Visible>
<Group>

View file

@ -5,6 +5,7 @@ using OnTopReplica.Properties;
using System.Threading;
using System.Globalization;
using System.Drawing;
using System.IO;
namespace OnTopReplica
{
@ -14,6 +15,9 @@ namespace OnTopReplica
/// </summary>
[STAThread]
static void Main() {
//Hook abort handler
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
//Update settings if needed
if (Settings.Default.MustUpdate) {
Settings.Default.Upgrade();
@ -70,5 +74,28 @@ namespace OnTopReplica
return true;
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
string dump = string.Format("OnTopReplica-dump-{0}{1}{2}{3}{4}.txt",
DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day,
DateTime.UtcNow.Hour, DateTime.UtcNow.Minute);
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), dump);
using (var s = new FileStream(path, FileMode.Create)) {
using (var sw = new StreamWriter(s)) {
sw.WriteLine("OnTopReplica Dump file");
sw.WriteLine("This file has been created because OnTopReplica crashed.");
sw.WriteLine("Please send it to lck@klopfenstein.net to help fix the bug that caused the crash.");
sw.WriteLine();
sw.WriteLine("Last exception:");
sw.WriteLine(e.ExceptionObject.ToString());
sw.WriteLine();
sw.WriteLine("OS: {0}", Environment.OSVersion.ToString());
sw.WriteLine(".NET: {0}", Environment.Version.ToString());
sw.WriteLine("Aero DWM: {0}", VistaControls.OsSupport.IsCompositionEnabled);
}
}
}
}
}

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.9.4.0")]
[assembly: AssemblyFileVersion("2.9.4.0")]
[assembly: AssemblyVersion("2.9.5.0")]
[assembly: AssemblyFileVersion("2.9.5.0")]