[Mono-list] Buggy IDispose handling

Jörg Pommnitz jpo@joerg-pommnitz.de
Thu, 02 Jan 2003 22:14:34 +0100

Hi List,
the following example program from TiC# shows a bug in Mono's handling
of disposable objects inside a using() statement:

using System;

class UsingCleanup : IDisposable {
  public static void Main(){
      UsingCleanup uc = new UsingCleanup();
        throw new NotImplementedException();
       Console.WriteLine("Exception ignored");
    Console.WriteLine("Leaving Main( )");

    Console.WriteLine("Constructor called");

  public void Dispose(){
    Console.WriteLine("Dispose called");

    Console.WriteLine("Destructor called");

Under Microsoft's .NET runtime I get:

Constructor called
Dispose called
Exception ignored
Leaving Main( )
Destructor called

while Mono 0.17 results in the following output:
 > mono UsingCleanup.exe
Constructor called
Exception ignored
Leaving Main( )
Destructor called

As you can see, the call to Dispose is missing. This could easily lead 
to a ressource leak.
Is this a known bug or should I file it?

Regards and a successful 2003 for everybody in the Mono team