Basically, I suspect the problem is that your code isn't running!
I copied your code into a console app and tried it:
class Program
{
public static void Main(string[] arg)
{
MyClass class_A = new MyClass();
DoWork();
}
public static void DoWork()
{
Console.WriteLine("In Do work");
MyClass class_B = new MyClass();
}
}
public class MyClass
{
public MyClass()
{
}
~MyClass()
{
Console.WriteLine("Object destroied");
}
}
And sure enough, using the debugger I could see that the destructor method was indeed called twice.
Did you really call your method "main"? Or did you use "Main"? C# is case sensitive, so the former would not be run automatically.