Why is a control destroyed twice when it's nested in a tab control?
I've been trying to debug why closing windows forms designer is crashing visual studio and have discovered by adding开发者_如何学Go a series of message boxes that if my controls are nested inside a System::Windows::Forms::TabControl
the destructor of those controls are called twice.
Is that expected behaviour and is there a way of avoiding it?
The Dispose() method may be called more than once, there is no rule that says it isn't legal. If you do override it (implement the destructor in C++/CLI) then you have to make sure that your code is resilient to this. Very commonly done with an isDisposed field in the class.
精彩评论