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:
-
-
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)
-
{
-
}
-
}
-
- 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