Esempio n. 1
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     try
     {
         var ex = e.ExceptionObject as Exception;
         if (ex != null)
         {
             DDLogManager.GetLogger(typeof(Program)).LogFatal(ex);
         }
     }
     finally
     {
         Application.Exit();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Executes a <see cref="ShellCommand"/> replacing the placeholders with the specified value.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="replacements">The placeholders and their values to replace them with.</param>
        public static void ExecuteCommand(ShellCommand command, IEnumerable <KeyValuePair <string, string> > replacements)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            try
            {
                Process.Start(command.ToProcessStartInfo(replacements));
            }
            catch (Exception ex)
            {
                DDLogManager.GetLogger(typeof(ShellExecutor)).LogException(ex);
                //For now we just alert the user; maybe someday we'll use something more sophisticated than a messagebox
                MessageBox.Show(string.Format("{0}\r\n[{1}]", ex.Message, ex.GetType().Name), Properties.Resources.shellexecutor_errorexecutecmd, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }