Tag: C# .NET

情報

コーディング規約

プロパティ

WOW64

コレクション

正規表現

インターフェース

例外

アプリケーション例外補足

static void Main()
{
...
 Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
 Thread.GetDomain().UnhandledException += new UnhandledExceptionEventHandler(Application_UnhandledException);
...
}

public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
   ShowErrorMessage(e.Exception, "Application_ThreadException error.");
}

public static void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
   Exception ex = e.ExceptionObject as Exception;
   if (ex != null)
   {
      ShowErrorMessage(ex, "Application_UnhandledException error.");
   }
}

ログ

Traceをファイル出力

StreamWriter sw = new StreamWriter("log.txt");
sw.AutoFlush = true;
TextWriter tw = TextWriter.Synchronized(sw);
TextWriterTraceListener twtl = new TextWriterTraceListener(tw, "LogFile");
Trace.Listeners.Add(twtl);

Traceにメソッド名を出力

Trace.WriteLine(DateTime.Now.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

文字列

アセンブリ

並行処理

スレッド


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS