Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
38 lines (35 loc) · 1.42 KB
/
Copy pathProgram.cs
File metadata and controls
38 lines (35 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MicMute
{
static class Program
{
public static MainForm mf = null;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += (s, e) => LogError(e.Exception);
AppDomain.CurrentDomain.UnhandledException += (s, e) => LogError(e.ExceptionObject as Exception);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mf = new MainForm();
Application.Run(mf);
}
// Writes the error to %TEMP%\MicMute-error.log and shows it.
static void LogError(Exception ex)
{
string text = DateTime.Now + Environment.NewLine + ex + Environment.NewLine + Environment.NewLine;
string path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MicMute-error.log");
try { System.IO.File.AppendAllText(path, text); } catch { }
MessageBox.Show(ex?.Message + Environment.NewLine + Environment.NewLine + "Details: " + path, "MicMute error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}