"Window handle already exists" exception when setting ErrorProvide

  • Thread starter Thread starter Flack
  • Start date Start date
F

Flack

Hey guys,
I am seeing some behavior I don't understand.

I have two custom user controls, a calendar control and a small dialog type
form. In the forms constructor, it validates a number of dates using the
calendar control. If the calendar control sees a date is invalid, it updates
its ErrorProvider by calling ErrorProvider.SetError.

In VS2008 everythin works fine, but in 2005, the second time the SetError
call is made, I get the exception

System.InvalidOperationException: Window handle already exists.
at System.Windows.Forms.NativeWindow.CheckReleased()
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)

Can someone explain to me what this error means exactly or what can be
causing it? If the handle exists, why would SetError of the ErrorProvider
try to create it again?

Another thing I don't quit understand is that by moving the code I had in
the form's constructor to its OnLoad event, everything works fine.

Any ideas?

Thanks.
 
Back
Top