1
Vote

BaseValidatorManager.DeRegisterBaseValidator(this) method is not called until app closes.

description

By design BaseValidatorManager.RegisterBaseValidator is called when new validator instance is created.
Designer creates instance of control in InitializeComponent() method, initializing object similary to
this.requiredFieldValidator1 = new Genghis.Windows.Forms.RequiredFieldValidator();
 
BaseValidatorManager.DeRegisterBaseValidator(this) is called in component Dispose() method.
 
Unfortunately, BaseValidator.Dispose() does not execute when form closes, leaving all controls in registered BaseValidatorManager.
If tends to block object finalization, due to pinned strong ref beeing held to validation controls.
 
As an example, here's a dump from windbg session (gcroot):
DOMAIN(00000000003A1230):HANDLE(Pinned):3017d0:Root:000000001275a738(System.Object[])->
0000000002780f90(Genghis.Windows.Forms.BaseValidatorCollection)->
0000000002780fb0(System.Object[])->
000000000277e6a0(Genghis.Windows.Forms.RequiredFieldValidator)->
000000000277d288(System.Windows.Forms.TextBox)

comments