Skip to content

Commit

Permalink
First commit of CrashCatcher app
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonleenaylor committed Nov 22, 2017
0 parents commit aeb14d7
Show file tree
Hide file tree
Showing 13 changed files with 645 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/obj/
**/.vs/
**/artifacts/
22 changes: 22 additions & 0 deletions CrashCatcher/CrashCatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Windows.Forms;

namespace CrashCatcher
{
/// <summary>
/// This program is built to try and extract as much error information as possible from a program that crashes
/// on start-up with errors like FileLoadException where all you get is a windows event log message with
/// no useful info.
/// </summary>
static class CrashCatcher
{
/// <summary/>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new DropWindow());
}
}
}
86 changes: 86 additions & 0 deletions CrashCatcher/CrashCatcher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FEDEEF15-7E85-4DBB-96AB-8C8EB3570A97}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CrashCatcher</RootNamespace>
<AssemblyName>CrashCatcher</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>artifacts\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>artifacts\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DropWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DropWindow.Designer.cs">
<DependentUpon>DropWindow.cs</DependentUpon>
</Compile>
<Compile Include="CrashCatcher.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="DropWindow.resx">
<DependentUpon>DropWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
22 changes: 22 additions & 0 deletions CrashCatcher/CrashCatcher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashCatcher", "CrashCatcher.csproj", "{FEDEEF15-7E85-4DBB-96AB-8C8EB3570A97}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FEDEEF15-7E85-4DBB-96AB-8C8EB3570A97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FEDEEF15-7E85-4DBB-96AB-8C8EB3570A97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FEDEEF15-7E85-4DBB-96AB-8C8EB3570A97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEDEEF15-7E85-4DBB-96AB-8C8EB3570A97}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
69 changes: 69 additions & 0 deletions CrashCatcher/DropWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions CrashCatcher/DropWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace CrashCatcher
{
public partial class DropWindow : Form
{
public DropWindow()
{
InitializeComponent();
components = new Container();
}

private void OnDrop(object sender, DragEventArgs e)
{
var dropData = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
var pi = new ProcessStartInfo(dropData)
{
WorkingDirectory = Path.GetDirectoryName(dropData),
RedirectStandardError = true,
UseShellExecute = false
};
try
{
var process = Process.Start(pi);
process.WaitForExit();
if (process.ExitCode == 0)
{
resultsBox.Text = "Looks like it worked.";
}
else
{
resultsBox.Text = "Something blew up." + Environment.NewLine + process.StandardError.ReadToEnd();
}
}
catch (Exception crash)
{
var realCrash = crash.InnerException;
if (realCrash == null)
realCrash = crash;
resultsBox.Text = realCrash.Message + Environment.NewLine + realCrash.StackTrace;
Refresh();
}
}

private void DropWindow_DragEnter(object sender, DragEventArgs e)
{
resultsBox.Text = string.Empty;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
var dropData = (string[])e.Data.GetData(DataFormats.FileDrop);
if (dropData.Length == 1 && dropData[0].EndsWith(".exe"))
{
e.Effect = DragDropEffects.Copy;
}
else
{
resultsBox.Text = "Drop one .exe file here at a time.";
}
}
}

private void DropWindow_DragLeave(object sender, EventArgs e)
{
}
}
}
Loading

0 comments on commit aeb14d7

Please sign in to comment.