473,327 Members | 2,103 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,327 software developers and data experts.

ObjectDisposedException On Application.Run()

19
Hello,
I have been trying to get my application to try and load config in from an xml file, however i want it to bring up a config window if it fails to load the configuration. However when i close the form used in Program.cs/Application.Run(new Form()) and try to open the config form the program crashes because the Application.Run() loop is still looking for the main form, i have tried a few things like Application.Run() without arguments etc but it just makes no forms show up.

Here are some code examples:
Expand|Select|Wrap|Line Numbers
  1.  
  2. public partial class StartScreen : Form     
  3. {
  4.          public StartScreen()
  5.          {
  6.             InitializeComponent();
  7.             ClientCare_Session.StartWindowInstance = this;
  8.             if (!ClientCare_Session.Started)
  9.                  ClientCare_Session.StartSession();
  10.          }
  11.           private void StartScreen_Load(object sender, EventArgs e)
  12.          {
  13.          }
  14.      }
  15.  
Expand|Select|Wrap|Line Numbers
  1.  public static void StartSession() 
  2.         { 
  3.             Started = true; 
  4.             LoadConfig(); 
  5.             ClientCare_Database.Install(); 
  6.         }
  7.         public static void LoadConfig()
  8.         {
  9.             try
  10.             {
  11.                 XmlDocument doc = new XmlDocument(); 
  12.                 XmlNodeReader reader; 
  13.                 XmlNode node; 
  14.                 doc.Load(String.Format("{0}\\{1}", ClientCare_Session.AppPath, ConfigFile)); 
  15.                 node = doc.DocumentElement.SelectSingleNode("MySQL"); 
  16.                 reader = new XmlNodeReader(node); 
  17.                 while (reader.Read())
  18.                 {
  19.                     switch (reader.Name)
  20.                     {
  21.                         case "Username": { break; }
  22.                     }
  23.                 }
  24.             }
  25.             catch (Exception)
  26.             {
  27.                 ClientCare_Config form = new ClientCare_Config(true); form.Show(); StartWindowInstance.Hide();
  28.             }
  29.         }
thank you for any help
Oct 25 '08 #1
1 1886
Plater
7,872 Expert 4TB
Don't load the config from withen the form object.
Load it before hand. It it fails, popup your config window, if it succeeds pop open your regular window?
Oct 27 '08 #2

Sign in to post your reply or Sign up for a free account.

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...
0
by: Richard Blewett [DevelopMentor] | last post by:
In theory there is nothing wrong with the Windows Forms part of your application (using your code as a start I mocked up the app and can happily press the connect and disconnect buttons...
0
by: Darrell Wesley | last post by:
I'm getting at the end of the application a "ObjectDisposedException was unhandled" warning with the statement that "safe handle has been closed". What does that mean? The application is building...
2
by: KJAbbott | last post by:
I have developed an application in VS 2005 for the Compact Framework. This application makes asynchronous web service calls on a timer. If the application is closed at a random time it will throw...
3
by: Martin Pöpping | last post by:
Hello, I´ve a problem with a small line of code. For my Windows Application I designed a form for exporting data into xml files. I´m opening the dialog with: ExportDialog export = new...
2
by: Bernard Borsu | last post by:
Hi ! My website breakdown at least 20 times per day with a System.ObjectDisposedException. The only information available are those given by the httpmodule treating the unhandledexception...
0
by: sdanda | last post by:
Hai i am working on vb.net. In my application I created four forms.Those are first.vb,f1.vb,f2.vb and f3.vb In firstvb I added 3 checkboxes and a "display" button.The 3 checkboxes are used to...
5
by: Brian | last post by:
Hello all. I have a simple application that I was using to test and understand the System.Timers.Timer and noticed that when I stop the application, on occasion, it throughs the following...
2
by: LLcoolQ | last post by:
I have created a DataGridViewNumericUpDownColumn using this from MSDN: http://msdn.microsoft.com/en-us/library/aa730881(vs.80).aspx I build my grids at run-time, here is the code for adding the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.