locked
Exception??? RRS feed

  • Question

  • System.ObjectDisposedException: Cannot access a disposed object named "DataGridTextBox". Object name: "DataGridTextBox"......I am getting this exception and unfortunaltly i dont know why or how to catch the exception so i know what line of code is throwing this....any help on how i can get this error handeled????
    Thursday, November 16, 2006 3:42 PM

Answers

  • Go to menu item "Debug->Exceptions...", find ObjectDisposedException and set "Break when exception is thrown" instead of "Break when exception is unhandled". In VS.NET 2003 it will be slightly different, but you'll easily find this setting.

    After that run your app and you should fall to debugger at the place where this exception is thrown.

    Thursday, November 16, 2006 10:35 PM

All replies

  • step through the debugger and see at what line the exception happens on. Usually it will take you to that line. You are trying to access/use an object that has been disposed of. It's an ObjectDisposedException so you are doing something after the object has been disposed of
    Thursday, November 16, 2006 3:46 PM
  • The reason of exception is quite clear from the message it is showing. You are trying to interact somewhere in your code with a disposed object "DataGridTextBox".

    To get the exact line of code, use try/catch block around the block of code and use StackTrace Property to see from where this was raised.

    I hope this will help in understanding the problem and correcting it!

    Best Regards,

    Rizwan

    Thursday, November 16, 2006 7:00 PM
  • Right this exception happens when i just close the form....so how would i catch that....would i wrap the entire form in a try catch block??? I dont think i can do that....when i close the form with the x button in the top right corner i get the exception and i dont have any Form Closing events.....
    Thursday, November 16, 2006 9:02 PM
  • well if this is happening when you are closing the form then it gets trickier. are you sure you are not accessing this object from some where else, such as form_closing method or something at the time? Something which may trigger to update the object or something? What about any events the datagridtextbox has? perhaps those events are getting fired?
    Thursday, November 16, 2006 9:14 PM
  • Go to menu item "Debug->Exceptions...", find ObjectDisposedException and set "Break when exception is thrown" instead of "Break when exception is unhandled". In VS.NET 2003 it will be slightly different, but you'll easily find this setting.

    After that run your app and you should fall to debugger at the place where this exception is thrown.

    Thursday, November 16, 2006 10:35 PM
  • Actually when i do this it throws all kinds of exceptions that i never thought i had.....It does not have that exception that i am looking for....I am using VS 2003 but can not find where it will list the exception that has been thrown....
    Friday, November 17, 2006 12:21 AM
  • In VS2003 go to Debug->Exceptions...
    Then go to "Common Language Runtime Exceptions->System->ObjectDisposedException" and set
    "When the exception is thrown" to "Break into the debugger"

    Moreover you can add your exception type by selecting the appropriate category and clicking "Add...". Just specify the full class name with namespace.
    Friday, November 17, 2006 6:32 AM