Results 1 to 4 of 4

Thread: [RESOLVED] Reading app.config

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Resolved [RESOLVED] Reading app.config

    HI all using the following code.

    Code:
    //Should just bring back my name from a config file
    try
    	{							
    		string x =ConfigurationSettings.AppSettings["name"].ToString();
    		MessageBox.Show(x.ToString());
    	}
    	catch(ConfigurationException ce)
    	{
    		MessageBox.Show(ce.Message);
    	}
    	catch(Exception ge)
           {
    	       MessageBox.Show(ge.Message);
    	}
    Works fine in the IDE but when i run the release version I get the following exception message.

    Object reference not set to an instance of an object
    ANy help would be greatly appreciated!!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Reading app.config

    What happens when you change the key 'name' to something else, like 'myname'?

  3. #3

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: Reading app.config

    Still the same, my config file looks like so.

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.windows.forms jitDebugging="true" />
    <appSettings>
    
    <add key="name" value="BombDrop"/>
    
    </appSettings>
    </configuration>
    the thing thatg really gets me is that it works in the ide but not from the release exe?

  4. #4

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: Reading app.config

    Sorry abousolute stupid idiot I was running the exe from the object file insted of the bin folder\release

    sorry guys

Posting Permissions

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



Click Here to Expand Forum to Full Width