Announcement

Collapse
No announcement yet.

Exception Handling

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception Handling

    Möchte den Exception-Handler
    von Dot-net unterbinden, so dass er sich bei
    einem eventuellen Bug nicht meldet, und nur die Anwendung
    schliesst.
    Am schönsten wäre es wenn anstatt dessen ein LOG-Eintrag
    in einer bestimmten Datei stattfinden würde.

    Wie geht das ?
    Vielen Dank.

  • #2
    Hallo,

    zB
    [highlight=c#]
    using System;
    using System.Windows.Forms;

    namespace WindowsFormsApplication1
    {
    static class Program
    {
    [STAThread]
    static void Main()
    {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(fals e);

    try
    {
    Application.Run(new Form1());
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }
    }
    }
    [/highlight]

    Wobei anstatt der MessagBox dein Eintrag in eine Datei geschrieben werden kann.
    [highlight=c#]
    using (StreamWriter sw = new StreamWriter("Error.log", true))
    {
    sw.WriteLine(ex.Message);
    }
    [/highlight]

    mfG Gü
    "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

    Comment

    Working...
    X