Example #1
0
        /// <summary>
        /// アプリケーションのメイン エントリ ポイントです。
        /// </summary>
        static void Main()
        {
            try
            {
                Application.Run(new MainForm());

                // 終了処理
                try
                {
                    // 終了時処理
                    TwitterAwaySpecificProcess.ExitDisable();
                }
                catch (IOException)
                {
                    MessageBox.Show("設定ファイルが書き込めませんでした", "設定ファイル書き込みエラー");
                }
            }
            catch (Exception ex)
            {
                // ログに例外情報を書き込む
                Log           exceptionLog = new Log(AssemblyUtility.GetExecutablePath() + @"\" + TwitterAwayInfo.ExceptionLogFile);
                StringBuilder error        = new StringBuilder();


                error.Append("Application:       " +
                             TwitterAwayInfo.ApplicationName + " " + TwitterAwayInfo.VersionNumber + "\r\n");
                error.Append("Date:              " +
                             System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\r\n");
                error.Append("OS:                " +
                             Environment.OSVersion.ToString() + "\r\n");
                error.Append("Culture:           " +
                             System.Globalization.CultureInfo.CurrentCulture.Name + "\r\n");
                error.Append("Exception class:   " +
                             ex.GetType().ToString() + "\r\n");
                error.Append("ToString:   " +
                             ex.ToString() + "\r\n");
                error.Append("Exception message: "
                             + "\r\n");
                error.Append(ex.Message);

                Exception innnerEx = ex.InnerException;
                while (innnerEx != null)
                {
                    error.Append(innnerEx.Message);
                    error.Append("\r\n");
                    innnerEx = innnerEx.InnerException;
                }

                error.Append("\r\n");
                error.Append("\r\n");

                exceptionLog.LogThis(error.ToString(), Log.LogPrefix.date);

#if DEBUG
                // デバッガで例外内容を確認するため、例外をアプリケーションの外に出す
                throw ex;
#else
                Trace.Assert(false, "予期しないエラーが発生したため、終了します");
#endif
            }
        }