[.NET2] Exception + Dispose
От: Аноним  
Дата: 03.11.10 07:17
Оценка:
Куда пропадает Exception "Error in Process" в приведённом коде?

using System;

namespace ConsoleApplication5
{
    public class A : IDisposable
    {
        public void Process()
        {
            Console.WriteLine("Process - begin");
            throw new NotImplementedException("Error in Process");
        }

        public void Dispose()
        {
            Console.WriteLine("Dispose - begin");
            throw new NotImplementedException("Error in Dispose");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Main1 - Begin");

            try
            {
                using (A a = new A())
                {
                    a.Process();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.ToString());
                Console.WriteLine("InnerException: " + (ex.InnerException != null ? ex.InnerException.ToString() : "<null>"));
            }

            Console.WriteLine("Main1 - End");

            Console.ReadLine();
        }
    }
}
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.