Tuesday, September 17, 2002

.NET Bug: Problems Removing an ActiveX Control from its Parent

My colleague Darko Miletic and I have isolated this one: ActiveX controls hosted inside .NET apps attach a handler to the VisibleChanged event of their parent. But if you remove them from their parent they forget to detach that handler. Change the visibility of the parent in any way, and the program blows up.

Steps to reproduce:

  1. Create a form and place an ActiveX control and a button on it.
  2. Write a Click event handler for the button that removes the ActiveX control from the form.
  3. Run the app.
  4. Click on the button. The control should disappear.
  5. Try closing the form. Boom.

I've updated the .NET Bug Registry with this info.

   1:24 PM

Content of this site is © Dejan Jelovic. All rights reserved.