Thread: Application fails to load settings only at windows startup

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    129

    Application fails to load settings only at windows startup

    My program uses an XML to store it's settings by way of serialization. Everything is fine when attempting to load these settings when the program is started, except when the program is starting with windows.

    In the Form_Load event, the program does this:

    Code:
    try
    {
        LoadSettings();
    }
    catch
    {
        // error stuff
    }
    .....
    and LoadSettings() consists of:

    Code:
    XmlSerializer settingsXML = new XmlSerializer(typeof(SettingsClass));
    using (FileStream loadFile = new FileStream("settings.xml", FileMode.Open))
    {
    	Settings = (SettingsClass)settingsXML.Deserialize(loadFile);
    }
    No error is ever produced as far as I can manage to create one. Yet when windows is starting up the program is just blank, no matter what the settings are in the xml. Close the program and restart it, and the settings are loaded. What could be doing this?
    He who asks is a fool for five minutes, but he who does not ask remains a fool forever.

    The fool wonders, the wise man asks. - Benjamin Disraeli

    There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    290
    What method are you using to load the program at Windows startup?

    I just whipped up a test application that uses the XmlSerializer. It serializes a simple person class to disk when the main form closes, and de-serializes it from disk when the form loads. It also has some textboxes so I can edit the fields in the object.

    I set it to run my program at Windows startup by adding a shortcut to my application to the Startup folder. It works fine for me.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    129
    I'm using the registry method. I'll give the shortcut a try, just to be sure.
    He who asks is a fool for five minutes, but he who does not ask remains a fool forever.

    The fool wonders, the wise man asks. - Benjamin Disraeli

    There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    1

    Same Problem

    I had this same problem, and I came across this forum while trying to track down an answer. I finally found the issue to be with the "Start In" field of the shortcut to the program that is in my Startup folder.

    I had to set this "Start in" field to the location of the folder in which my program EXE resides. Now, everytime that I start up my computer (and the program automatically loads) it loads in the data and settings the way that it should.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GetDiskFreeSpace Windows API fails on windows 2000
    By dnyampawar in forum Windows Programming
    Replies: 7
    Last Post: 07-09-2009, 03:39 AM
  2. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  3. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  4. Windows Application Handles
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 06-15-2002, 05:09 PM
  5. MFC dialog application - how to update two windows
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 10-23-2001, 01:54 AM