Dispose a Form with an ActiveX control(AxHost).

  • Thread starter Thread starter rdascalescu
  • Start date Start date
R

rdascalescu

Hi,

Please if somebody knows how to dispose a Form which contain an ActiveX
control. If you place an ActiveX control in C# will be created an
interop(AxHost).
I can't release the memory used by these forms. I tried on

private void Form_Closed(object sender, System.EventArgs e)
{
this.Controls.Remove(this.ActiveXControl);
this.ActiveXControl.Parent = null;
this.ActiveXControl.Dispose();
this.ActiveXControl = null;
CollectGarbage(this.ActiveXControl);
}
static void CollectGarbage(object pFrm)
{
WeakReference wkref = new WeakReference(pFrm);
GC.SuppressFinalize(pFrm);
GC.Collect();
}
but was useless.

Please help.
Thanks
 
Back
Top