Killing COM object from C#
<p>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.</p>

<p>I've tried </p>

<pre><code>System.Runtime.InteropServices.Marshal.ReleaseComObject(myApp); 
GC.Collect(); 
GC.WaitForPendingFinalizers ();
myApp = null;
</code></pre>

<p>and I create it by</p>

<pre><code>myApplication.ApplicationClass myApp = new myApplication.ApplicationClass();
</code></pre>

<p>this is the full code
this com object is written in vb6, below is the C# code calling vb6 component</p>

<pre><code>      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))
</code></pre>

<p>{
 //Perform some action
}
else
                    {
                    throw new System.Exception(MESSAGE_LOGINERROR);
 }
}
Finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(myApp);</p>

<pre><code>            GC.Collect();
            GC.WaitForPendingFinalizers();
            M2MApp = null;
</code></pre>

<p>}</p>

<p>Thanks,
Pradeep</p>
