I ran across a problem after installing the .NET framework Service
Pack 1 on both XP and Server 2003, so I thought I would post the
solution here in case anyone else ran across it.
After installing the service pack on my development machine, I started
getting an ObjectDisposedException every time I hit the enter button
while in a TextBox. The top of the call stack said the errant method
was System.Windows.Forms.Control.CreateHandle(), and there was nothing
else in the call stack that pointed to anything in my code.
We tested several computers, with XP and 2003. The problem did not
occur before the Service Pack installation, and would start
immediately after the installation.
We are going live with our application in a few days, so needless to
say there were mild cases of panic.
About 5 levels down the call stack was a Button.OnClick() method,
which seemed strange since the error was coming from a TextBox. Then
it occured to me what the problem was. I have a login screen that
pops up when the app is launched. You have to set the AcceptButton
property of the main form to the 'OK' button on the login screen so
that hitting the 'Enter' button will start the login process. When
the user is logged in, the login screen gets disposed. The problem
was that when you hit enter while in a TextBox, the main form was
still trying to use the AcceptButton. So now when I dispose the login
control, I just set the AcceptButton property to null, and that fixes
the problem.
Now I don't know why this wasn't a problem before the service pack.
Was the form smart enough before to know it's AcceptButton was toast,
or was something crashing and the framework wasn't telling me?
Anyhow, I hope this helps someone else avoid a panic attack.
Gook luck,
Kevin Smith