I have a COM object that we are calling from C#. This works great, and I have my own pool of objects that I can use whenever I want. Now I need to kill the object. I've tried releasing the COM object explicitly and then garbage collecting from another thread, but that does nothing. Does anyone have any other ideas to kill this object? Thanks for the help.
I've tried
System.Runtime.InteropServices.Marshal.ReleaseComObject(myApp);
GC.Collect();
GC.WaitForPendingFinalizers ();
myApp = null;
and I create it by
myApplication.ApplicationClass myApp = new myApplication.ApplicationClass();
this is the full code this com object is written in vb6, below is the C# code calling vb6 component
myApplication.ApplicationClass myApp = new myApplication.ApplicationClass();
string user = this._User;
string pass = this._Pass;
string company = this.companyNumber;
try
{
if (myApp.Login(ref user, ref pass, ref company))
{ //Perform some action } else { throw new System.Exception(MESSAGE_LOGINERROR); } } Finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(myApp);
GC.Collect();
GC.WaitForPendingFinalizers();
M2MApp = null;
}
Thanks, Pradeep
ApplicationClassis from? Is it a microsoft excel/word instance wrapped underneath?