Bugzilla – Bug 313611
Finalize() method and NullPointerException
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by vguzev@yandex.ru 2004-01-16 06:19:46 MST ---- Description of Problem: When I declare and use Finalize() method the NullReferenceException is thrown Steps to reproduce the problem: 1. Write the following program (A.cs) 8<-------------------------------------------------------------- using System; public class A { public A() { Console.WriteLine( "Object a created!" ); } public static void Finalize() { Console.WriteLine( "Object a finalized!" ); } } public class B { public static void Main( string[] args ) { A a = new A(); A.Finalize(); } } 8<-------------------------------------------------------------- 2. Compile it mcs A.cs 3. Run it mono A.exe Actual Results: 8<-------------------------------------------------------------- Object a created! Unhandled Exception: System.NullReferenceException: A null value was found where an object instance was required in (unmanaged) .A:Finalize () in <0x00034> .B:Main (string[]) 8<-------------------------------------------------------------- Expected Results: 8<-------------------------------------------------------------- Object a created! Object a finalized! 8<-------------------------------------------------------------- How often does this happen? Always Additional Information: It was tested on Mono 0.28 ---- Additional Comments From lupus@ximian.com 2004-01-16 06:42:04 MST ---- Mcs bug, not in the runtime. *** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO52933 *** This bug was marked DUPLICATE in the database it was moved from. Changing resolution to "MOVED"