Example #1
0
        public static void LogException(Exception ex)
        {
            // add catch for unknown application exceptions to try and get closer to bug
            StringBuilder capture = new StringBuilder();

            //
            try
            {
                Exception e = ex;
                capture.Append(e.Message).Append(Environment.NewLine);
                while (e != null)
                {
                    capture.Append(new StackTrace(e, true).ToString()).Append(Environment.NewLine);
                    e = e.InnerException;
                }
                //
                string dir = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), WinAuthMain.APPLICATION_NAME);
                if (Directory.Exists(dir) == false)
                {
                    dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                }
                File.WriteAllText(Path.Combine(dir, "winauth.log"), capture.ToString());
            }
            catch (Exception) { }

            try
            {
                ExceptionForm report = new ExceptionForm();
                report.ErrorException = ex;
                report.TopMost        = true;
                if (_form != null && _form.Config != null)
                {
                    report.Config = _form.Config;
                }
                if (report.ShowDialog() == DialogResult.Cancel)
                {
                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception) { }
        }
Example #2
0
        public static void LogException(Exception ex, bool silently = false)
        {
            // add catch for unknown application exceptions to try and get closer to bug
            //StringBuilder capture = new StringBuilder(DateTime.Now.ToString("u") + " ");
            //try
            //{
            //	Exception e = ex;
            //	capture.Append(e.Message).Append(Environment.NewLine);
            //	while (e != null)
            //	{
            //		capture.Append(new StackTrace(e, true).ToString()).Append(Environment.NewLine);
            //		e = e.InnerException;
            //	}
            //	//
            //	LogMessage(capture.ToString());
            //}
            //catch (Exception) { }

            try
            {
                Logger.Error(ex);

                if (silently == false)
                {
                    var report = new ExceptionForm();
                    report.ErrorException = ex;
                    report.TopMost        = true;
                    if (_form != null && _form.Config != null)
                    {
                        report.Config = _form.Config;
                    }
                    if (report.ShowDialog() == DialogResult.Cancel)
                    {
                        Process.GetCurrentProcess().Kill();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #3
0
		public static void LogException(Exception ex)
		{
			// add catch for unknown application exceptions to try and get closer to bug
			StringBuilder capture = new StringBuilder();
			//
			try
			{
				Exception e = ex;
				capture.Append(e.Message).Append(Environment.NewLine);
				while (e != null)
				{
					capture.Append(new StackTrace(e, true).ToString()).Append(Environment.NewLine);
					e = e.InnerException;
				}
				//
				string dir = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), WinAuthMain.APPLICATION_NAME);
				if (Directory.Exists(dir) == false)
				{
					dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				}
				File.WriteAllText(Path.Combine(dir, "winauth.log"), capture.ToString());
			}
			catch (Exception) { }

			try
			{
				ExceptionForm report = new ExceptionForm();
				report.ErrorException = ex;
				report.TopMost = true;
				if (_form != null && _form.Config != null)
				{
					report.Config = _form.Config;
				}
				if (report.ShowDialog() == DialogResult.Cancel)
				{
					Process.GetCurrentProcess().Kill();
				}
			}
			catch (Exception) { }
		}
Example #4
0
		public static void LogException(Exception ex)
		{
			// add catch for unknown application exceptions to try and get closer to bug
			//StringBuilder capture = new StringBuilder(DateTime.Now.ToString("u") + " ");
			//try
			//{
			//	Exception e = ex;
			//	capture.Append(e.Message).Append(Environment.NewLine);
			//	while (e != null)
			//	{
			//		capture.Append(new StackTrace(e, true).ToString()).Append(Environment.NewLine);
			//		e = e.InnerException;
			//	}
			//	//
			//	LogMessage(capture.ToString());
			//}
			//catch (Exception) { }

			Logger.Error(ex);

			try
			{
				ExceptionForm report = new ExceptionForm();
				report.ErrorException = ex;
				report.TopMost = true;
				if (_form != null && _form.Config != null)
				{
					report.Config = _form.Config;
				}
				if (report.ShowDialog() == DialogResult.Cancel)
				{
					Process.GetCurrentProcess().Kill();
				}
			}
			catch (Exception) { }
		}