المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : UnhandledException



C# Programming
10-15-2012, 12:12 AM
Does anyone know why this code doenst work?(In a consonle Application)
it cant catch exceptions
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyException);

throw new ArgumentException("for test");
}

static void MyException(object sender, UnhandledExceptionEventArgs e)
{
Console.WriteLine(e.ExceptionObject);

}
}


Thanks
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )