Archives
-
XMLAuto version 2010
Ten years ago, I played with OLE Automation so we can write things such as the following, where Document represents an XML document:
-
Forcing event unsubscription
Given my own experience, I'd say that events are the main source of leaks in .NET. They deserve double- and even triple-checks. Each time you add a subscription to an event in your code, most likely with +=, you should worry about the consequences and ask yourself whether you need to add a -= somewhere to unsubscribe from the event. If you have to, do it immediately before you forget about it. Often, you'll do that in a Dispose method.