I have an assembly that have drag dropped a COM Interop VB 6.0 text editor in it and been using it as a .NET wrapped control…
Then in a new assembly that is a windows form I drag drop the assembly above and start using it, declare a variable of it and assign event handlers to it so for example if Assmbley abvoe is namved MyTextControl then in this windows form I have a variable of mytxtcntrl and some event handlers for it like
mytxtcntrl.TextEditor.ObjectDblClicked += new AxTextEditorLib._DTextEditorEvents_ObjectDblClickedEventHandler(ctlTEEditor_ObjectDblClicked);
So now Sholud I even worry about removing these event handlers with “-=” ? or GC will take care of it?
If I should do it manually then what is the correct place to do it? I put them in Form_Closed section and ran a memory profiler, it didn’t have any effect.
No, you shouldn’t. The GC will take care of it. The only place where you need to worry about “trowing away” objects, is when you are using a class which implements
IDisposableor when you’re doing stuff withSystem.Runtime.InteropServices.