Esempio n. 1
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            // For the GUI thread exception handling only, check if there's a crash logger available,
            //  because we will have prevented it from seeing the AppDomain.CurrentDomain.UnhandledException event.
            if (CrashLogger != null)
            {
                CrashLogger.LogException(e.Exception);
            }

            ShowExceptionDialog(e.Exception);
            e.Handled = true;
        }
        private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            Exception exception = e.Exception;

            // For the GUI thread exception handling only, check if there's a crash logger available,
            //  because we will have prevented it from seeing the AppDomain.CurrentDomain.UnhandledException event.
            if (CrashLogger != null)
            {
                CrashLogger.LogException(exception);
            }

            ShowExceptionDialog(exception);
        }
Esempio n. 3
0
        // Code to execute on Unhandled Exceptions
        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            var flurry = Container.Resolve <FlurryPublisher>();

            flurry.PublishException(e.ExceptionObject);
            flurry.EndSession();
            CrashLogger.SaveCrashInfo(e);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                // An unhandled exception has occurred; break into the debugger
                System.Diagnostics.Debugger.Break();
            }
        }
Esempio n. 4
0
    static void Main(params string[] args)
    {
      System.Threading.Thread.CurrentThread.Name = "Manager";
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);

      // Parse Command Line options
      CommandLineOptions mpArgs = new CommandLineOptions();
      try
      {
        CommandLine.Parse(args, mpArgs);
      }
      catch (ArgumentException)
      {
        mpArgs.DisplayOptions();
        return;
      }

      using (new ServiceScope(true)) //This is the first servicescope
      {
        ApplicationCore.RegisterCoreServices();

        IPathManager pathManager = ServiceScope.Get<IPathManager>();
        // Check if user wants to override the default Application Data location.
        if (mpArgs.IsOption(CommandLineOptions.Option.Data))
          pathManager.ReplacePath("DATA", (string)mpArgs.GetOption(CommandLineOptions.Option.Data));

        //Check whether the user wants to log method names in the logger
        //This adds an extra 10 to 40 milliseconds to the log call, depending on the length of the stack trace
        bool logMethods = mpArgs.IsOption(CommandLineOptions.Option.LogMethods);
        LogLevel level = LogLevel.All;
        if (mpArgs.IsOption(CommandLineOptions.Option.LogLevel))
        {
          level = (LogLevel)mpArgs.GetOption(CommandLineOptions.Option.LogLevel);
        }
        ILogger logger = ServiceScope.Get<ILogger>();
        logger.Level = level;
        logger.LogMethodNames = logMethods;

        logger.Debug("Manager: Registering Strings Manager");
        ServiceScope.Add<ILocalisation>(new StringManager());

#if !DEBUG
        // Not in Debug mode (ie Release) then catch all Exceptions
        // In Debug mode these will be left unhandled.
      try
      {
#endif
        // Start the system
        logger.Debug("ApplicationLauncher: Starting MediaPortal manager");

        IPluginManager pluginManager = ServiceScope.Get<IPluginManager>();
        pluginManager.Initialize();
        pluginManager.Startup(true);
        Application.Run(new MainWindow());
        pluginManager.Shutdown();

#if !DEBUG
        }
        catch (Exception ex)
        {
          CrashLogger crash = new CrashLogger(pathManager.GetPath("<LOG>"));
          crash.CreateLog(ex);
          //Form frm =
          //  new YesNoDialogScreen("MediaPortal 2", "Unrecoverable Error",
          //                        "MediaPortal has encountered an unrecoverable error\r\nDetails have been logged\r\n\r\nRestart?",
          //                        BaseScreen.Image.bug);
          //restart = frm.ShowDialog() == DialogResult.Yes;
        }
#endif
      }
    }
Esempio n. 5
0
        static void Main(params string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Manager";
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Parse Command Line options
            CommandLineOptions mpArgs = new CommandLineOptions();

            try
            {
                CommandLine.Parse(args, mpArgs);
            }
            catch (ArgumentException)
            {
                mpArgs.DisplayOptions();
                return;
            }

            using (new ServiceScope(true)) //This is the first servicescope
            {
                ApplicationCore.RegisterCoreServices();

                IPathManager pathManager = ServiceScope.Get <IPathManager>();
                // Check if user wants to override the default Application Data location.
                if (mpArgs.IsOption(CommandLineOptions.Option.Data))
                {
                    pathManager.ReplacePath("DATA", (string)mpArgs.GetOption(CommandLineOptions.Option.Data));
                }

                //Check whether the user wants to log method names in the logger
                //This adds an extra 10 to 40 milliseconds to the log call, depending on the length of the stack trace
                bool     logMethods = mpArgs.IsOption(CommandLineOptions.Option.LogMethods);
                LogLevel level      = LogLevel.All;
                if (mpArgs.IsOption(CommandLineOptions.Option.LogLevel))
                {
                    level = (LogLevel)mpArgs.GetOption(CommandLineOptions.Option.LogLevel);
                }
                ILogger logger = ServiceScope.Get <ILogger>();
                logger.Level          = level;
                logger.LogMethodNames = logMethods;

                logger.Debug("Manager: Registering Strings Manager");
                ServiceScope.Add <ILocalisation>(new StringManager());

#if !DEBUG
                // Not in Debug mode (ie Release) then catch all Exceptions
                // In Debug mode these will be left unhandled.
                try
                {
#endif
                // Start the system
                logger.Debug("ApplicationLauncher: Starting MediaPortal manager");

                IPluginManager pluginManager = ServiceScope.Get <IPluginManager>();
                pluginManager.Initialize();
                pluginManager.Startup(true);
                Application.Run(new MainWindow());
                pluginManager.Shutdown();

#if !DEBUG
            }
            catch (Exception ex)
            {
                CrashLogger crash = new CrashLogger(pathManager.GetPath("<LOG>"));
                crash.CreateLog(ex);
                //Form frm =
                //  new YesNoDialogScreen("MediaPortal 2", "Unrecoverable Error",
                //                        "MediaPortal has encountered an unrecoverable error\r\nDetails have been logged\r\n\r\nRestart?",
                //                        BaseScreen.Image.bug);
                //restart = frm.ShowDialog() == DialogResult.Yes;
            }
#endif
            }
        }