dcsimg
Results 1 to 5 of 5
  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2018
    Posts
    1

    Resolved Object Disposed Exception

    I am also having great difficulty with the 'object disposed exception was unhandled' error. Single-form app written 5 years ago in VB 2008. Form has a tab control with 2 tabs. 1st tab has a RichTextBox control, 2nd tab has a WebBrowser control. User inputs some information and clicks a button whereby webbrowser is instructed to nagivate to a page and when loading is complete, runs through code to clean-up the text in the web browser an save contents to a file in RTF format. As a final step, I use the "RichTextBox1.LoadFile(AlertSearchResultFile, RichTextBoxStreamType.RichText)" to load the contents of the RTF-formatted ASCII text file into the RichTextBox on the 1st tab (which remains in focus throughout this whole process). Now, VB 2008 is throwing the object disposed exception on the loadfile command. Have searched the web high and low for guidance on figuring out why this is happening. There is no code disposing/closing the form or any of its controls. Any ideas on what I may do about this problem would be much appreciated. I should also say that the debugger stops on the richtexbox1.loadfile statement. To test the statement I added a button to the tab where the RichTextBox control is, which is what's visible when the form loads. I DIM'd AlertSearchResultFile and added the loadfile statement and ran the debugger again, pressed the button, and the file contents loaded in the RTB control. -But it will not do this from within other code. Again, any ideas would be greatly, GREATLY appreciated! -Thank You!

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,927

    Re: [RESOLVED] Object Disposed Exception

    @BillFlett, if someone has marked their thread Resolved and the information it contains does not help you then your issue is likely different. In that case, you really ought to start your own thread. Many people won't bother opening a Resolved thread either, so having your own thread will likely get you more views and a better chance of getting help. You can always provide a link to an existing thread if it might be relevant. I'm asking the mods to break your post out into its own thread.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,144

    Re: Object Disposed Exception

    Split to new thread, as it is far more likely to get answered that way.
    My usual boring signature: Nothing

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,927

    Re: Object Disposed Exception

    Can you provide the simplest set of steps that we can follow to reproduce the issue, or else provide the simplest possible project that demonstrates it? It would appear that your RichTextBox is getting disposed somewhere, somehow but there's really no way that we can tell where or how from what you've described.

    I would also like to point out that this really does sound unrelated to the issue in the other thread. That was on closing a form, if I remember correctly. The fact that the same exception is thrown doesn't really mean that the issues are related.
    Last edited by jmcilhinney; Feb 19th, 2018 at 07:35 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,580

    Re: Object Disposed Exception

    Does this only happen in debugging, and not at "real" runtime?

    Visual Studio has a feature where it catches "first-chance" exceptions. What this means is it stops as if there were a breakpoint at the line where an exception is thrown, before any other exception-handling logic has had a chance to run.

    Sometimes the things that Microsoft's code does in normal operation can throw exceptions. Often, those exceptions are caught inside Microsoft's code and safely handled. There are good reasons why that happens. But if you have first-chance exceptions and a couple of other options enabled, the debugger will break in those cases anyway. This can be really annoying to experts, and very confusing to newbies, because they don't realize it's not actually their own code that's throwing the exception.

    One sign this is what's happening is if the program runs fine outside of the debugger. That would indicate the exception happens, but is handled, because unhandled exceptions will crash an application. Another sign is if you push the "run" button in the debugger and the program chugs along with no problem. Again: only unhandled exceptions will cause an application crash. So if the application keeps running, this is probably what is happening.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.