No you are right, you need to create another COM object in order for the
stuff to work e.g.
class Class1
{
~Class1()
{
Console.WriteLine("I am being finalized");
}
static void Method1()
{
Class1 obj1 = new Class1();
Excel.ApplicationClass app = new
Excel.ApplicationClass();
app.Visible = true;
app = null;
obj1 = null;
GC.Collect();
string s = new string('9', 2);
Class1 obj2 = new Class1();
}
[STAThread]
static void Main(string[] args)
{
Method1();
Console.WriteLine("See if excel is running");
System.Threading.Thread.Sleep(3000);
}
}
This doesnot close excel but if instead I create another Excel object
following GC.Collect class Excel closes.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.