ObjectDisposedException On Application.Run()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alex21
    New Member
    • Oct 2008
    • 19

    #1

    ObjectDisposedException On Application.Run()

    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:
    Code:
        
    public partial class StartScreen : Form     
    {
             public StartScreen()
             {
                InitializeComponent();
                ClientCare_Session.StartWindowInstance = this;
                if (!ClientCare_Session.Started)
                     ClientCare_Session.StartSession();
             }
              private void StartScreen_Load(object sender, EventArgs e)
             {
             }
         }
    Code:
     public static void StartSession() 
            { 
                Started = true; 
                LoadConfig(); 
                ClientCare_Database.Install(); 
            }
            public static void LoadConfig()
            {
                try
                {
                    XmlDocument doc = new XmlDocument(); 
                    XmlNodeReader reader; 
                    XmlNode node; 
                    doc.Load(String.Format("{0}\\{1}", ClientCare_Session.AppPath, ConfigFile)); 
                    node = doc.DocumentElement.SelectSingleNode("MySQL"); 
                    reader = new XmlNodeReader(node); 
                    while (reader.Read())
                    {
                        switch (reader.Name)
                        {
                            case "Username": { break; }
                        }
                    }
                }
                catch (Exception)
                {
                    ClientCare_Config form = new ClientCare_Config(true); form.Show(); StartWindowInstance.Hide();
                }
            }
    thank you for any help
    Last edited by Plater; Oct 27 '08, 01:30 PM. Reason: line breaks are your friend
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    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?

    Comment

    Working...