I would appreciate any comments on this issue, as I cannot find any resources elsewhere.
Scenario:
In a Form, add a Control A and a Control B, where A subscribes to an event fired by B. I'm using
VB.NET, so that would be an AddHandler. Now make the Form delete Control A .
Problem:
Did you think you got rid of Control A? Think again, cause Control A is tied up to Control B through Control B's EventHandlerList. This is quite annoying since Control B doesn't know that Control A is deleted, and there is no way the Form can know there is more references to A. The consequence, if you have a lot of Control A's, is a major memoryleak.
Solution:
Help me out here. The only way I have found to avoid this mess is to force Control A to release it's eventhandlers with RemoveHandler. And the Form must call this method. Setting Control A to Nothing or just make the variable go out of scope doesn't help...
oes