If you get rid of the outer using you still get the error.  If you put code
inside the IF using, the error goes.  Code inside the ELSE using but not the
IF using, gives the error!

-----Original Message-----
From: Richard Blewett [mailto:[EMAIL PROTECTED]
Sent: 27 August 2003 17:35
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Nasty bug in 1.0 and 1.1 compiler


The code below executes both the if and the else in release build with
optimization turned on

<code>
    class DisposableClass : IDisposable
    {
        public void Dispose()
        {
        }
    }

    class Class1
    {
        static void Main(string[] args)
        {
            try
            {
                using ( new DisposableClass() )
                {
                    try
                    {
                        if ( args.Length == 0 )
                        {
                            Console.WriteLine("IN THE IF");
                            using ( new DisposableClass() )
                            {
                            }
                        }
                        else
                        {
                            Console.WriteLine("IN THE ELSE");
                            using ( new DisposableClass() )
                            {
                            }
                        }
                    }
                    catch ( Exception )
                    {
                    }
                }
            }
            catch ( Exception )
            {
            }

            Console.WriteLine("ending called");

        }
    }

</code>

commenting out the using block in the if block or putting code after the
using block in the if resolves the problem

Regards

Richard Blewett
DevelopMentor

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to