Exemple #1
0
        private static void handleUnhandledException(Exception exc)
        {
            bool useHandler = true;

            Trace.WriteLine(exc.ToString());
            if (useHandler)
            {
                FUnhandledExceptionHandler handler = new FUnhandledExceptionHandler(exc);
                handler.ApplicationName    = AssemblyTitle;
                handler.ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version;
                if (app != null)
                {
                    try
                    {
                        if (app.CommonCode.CurrentFilename != null)
                        {
                            handler.CurrentFilename.Add(app.CommonCode.CurrentFilename);
                        }
                    }
                    catch (NullReferenceException)
                    {
                    }
                }
                if (listener != null)
                {
                    try
                    {
                        Debug.Listeners.Remove(listener);
                        listener.Close();
                        listener.Dispose();
                        handler.CurrentFilename.Add(traceFile);
                    }
                    catch (Exception excLocal)
                    {
                        Trace.WriteLine(excLocal.ToString());
                    }
                }
                if (Application.MessageLoop)
                {
                    handler.Show();
                }
                else
                {
                    Application.Run(handler);
                }
            }
            else
            {
                MessageBox.Show("Ett allvarligt fel har uppstått: \"" + exc.ToString() + "\"",
                                "Major Failure",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
            }
            //Application.Exit();
        }
Exemple #2
0
        private static void HandleUnhandledException(Exception exc)
        {
            Trace.WriteLine("Unhandled Exception: " + exc);

            var handler = new FUnhandledExceptionHandler(exc)
            {
                ApplicationName    = AssemblyTitle,
                ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version
            };

            if (_app != null)
            {
                _app.UnhandledExceptionOccurred = true;

                try
                {
                    if (_app.CurrentFilename != null)
                    {
                        handler.CurrentFilename.Add(_app.CurrentFilename);
                    }
                }
                catch (NullReferenceException)
                {
                }
            }
            if (_listener != null)
            {
                try
                {
                    Debug.Listeners.Remove(_listener);
                    _listener.Close();
                    _listener.Dispose();
                    handler.CurrentFilename.Add(_traceFile);
                }
                catch (Exception excLocal)
                {
                    Trace.WriteLine(excLocal.ToString());
                }
            }
            if (Application.MessageLoop)
            {
                handler.Show();
            }
            else
            {
                Application.Run(handler);
            }
        }
		private static void HandleUnhandledException(Exception exc)
		{
			Trace.WriteLine("Unhandled Exception: " + exc);

			var handler = new FUnhandledExceptionHandler(exc)
			              	{
			              		ApplicationName = AssemblyTitle,
			              		ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version
			              	};
			if (_app != null)
			{
				_app.UnhandledExceptionOccurred = true;

				try
				{
					if (_app.CurrentFilename != null)
					{
						handler.CurrentFilename.Add(_app.CurrentFilename);
					}
				}
				catch (NullReferenceException)
				{
				}
			}
			if (_listener != null)
			{
				try
				{
					Debug.Listeners.Remove(_listener);
					_listener.Close();
					_listener.Dispose();
					handler.CurrentFilename.Add(_traceFile);
				}
				catch (Exception excLocal)
				{
					Trace.WriteLine(excLocal.ToString());
				}
			}
			if (Application.MessageLoop)
			{
				handler.Show();
			}
			else
			{
				Application.Run(handler);
			}
		}
		private static void handleUnhandledException(Exception exc)
		{
			bool useHandler = true;
			Trace.WriteLine(exc.ToString());
			if (useHandler)
			{
				FUnhandledExceptionHandler handler = new FUnhandledExceptionHandler(exc);
				handler.ApplicationName = AssemblyTitle;
				handler.ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version;
				if (app != null)
				{
					try
					{
						if (app.CommonCode.CurrentFilename != null)
						{
							handler.CurrentFilename.Add(app.CommonCode.CurrentFilename);
						}
					}
					catch (NullReferenceException)
					{
					}
				}
				if (listener != null)
				{
					try
					{
						Debug.Listeners.Remove(listener);
						listener.Close();
						listener.Dispose();
						handler.CurrentFilename.Add(traceFile);
					}
					catch (Exception excLocal)
					{
						Trace.WriteLine(excLocal.ToString());
					}
				}
				if (Application.MessageLoop)
				{
					handler.Show();
				}
				else
				{
					Application.Run(handler);
				}
			}
			else
			{
				MessageBox.Show("Ett allvarligt fel har uppstått: \"" + exc.ToString() + "\"",
					"Major Failure",
					MessageBoxButtons.OK,
					MessageBoxIcon.Stop);
			}
			//Application.Exit();
		}