I was under the impression that the event handlers of odjects that go out of scope are automatically removed from their respective events, which does not happen in the following case.
I have a static object that exposes some events. There is also another object derived from Form, which holds a Developer Express control (not sure if it matters), and it subscribes to the static object's events. Now comes the strange stuff. The first time the form is run, everything works great, but after the form is closed (and goes out of scope), and then opened again things don't work as expected. It took me a while to figure out what was going on, but I finally figured out thet somehow after the form is closed the event handlers don't get removed from the static object's events (delegates). After I added a manual removal of the event handlers in the form's Dispose method, everything worked as expected.
So, my question is the following. Do the event handlers really get removed from their respective events after the object goes out of scope, or this somehow does not apply to static objects ( !), or it has something to do with the mentioned control, or it is a bug in the compiler
Thanks.