473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

AcceptButton causes ObjectDisposedException

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
Nov 22 '05 #1
0 1200

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kevin Smith | last post by:
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...
1
by: xmlguy | last post by:
PREVIOUS BACKGROUND POST: I am trying to reuse a Memory Stream for loading and transforming the xml it contains Basically I have defined following interfaces: Class Render {
0
by: Jeff Haumesser | last post by:
I have a form with the AcceptButton property set to a command button. I also have a RichTextBox on the same form. With the AcceptButton property set, I cannot enter a carriage return in the...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
1
by: Jeff | last post by:
Hello all. I'm trying to figure out exactly what is going on here. I'm getting different results on different forms, and it's driving me nuts. For example, I have a form called FormFinish....
3
by: js1300 | last post by:
Hello, I'm working on a set of forms inherited from the windows form. Within these forms I often use keyevents to perform certain functions i.e. 'return/enter in a textbox' to submit a value to a...
2
by: Barney | last post by:
Hi, This is my first query in google groups. I expect to donīt do it wrong, and excuse me for my english, i havenīt used it for years... Iīm making a user component that inherits from a textbox....
2
by: sonicm | last post by:
Hi, I have a search for where we want the user to enter the search criteria in at the top and press enter, then the results are shown in a datagrid which we set the focus to. Once they select...
1
by: Al Biheiri | last post by:
how do i create an AcceptButton in c# user presses enter on textbox = button1.click something like AcceptButton = button1
1
by: Tony Johansson | last post by:
Hello! I'm reading a book which mentioned about this AcceptButton property for a form which seems quite easy so I try to figure out how it works but I have run into some small problems. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.