Okay, so a while ahead I posted how to read other config files of other programs (here is the link Previous Post. I managed to do it. But now there is another problem. The scena
I had the same problem, I don't know if this can help you but when I changed the name of the config file, which was in another folder as in your case, to .config and it didn't crash anymore, in my case I could change the name so I didn't continue the investigation how to make it work with other name, but of course I would like to know.
Well, I figured it out myself after debugging for almost 5 hours, Damn!
The problem was when I used OpenFileDialog to get the file path, it changed the current directory to the one which is selected in the dialog, so the program couldn't find the config file. All I did was to set the RestoreDirectory property of OpenFileDialog to true and poof it worked
Thanks everyone, ChrisF, Eoin Campbell and pablito.
What code are you using to get the FileName and Path back from the OpenFileDialog.
Is it a fully qualified path to the file ?
e.g.
openFileDialog1.FileName; //Contains "C:\\Path\\To\\The\\File.txt"
By the sounds of it, whats being saved is only a filename, so your application is only looking in the current path.
Are you accessing the file by its full path or just the file name?
If the latter then this will work when the file is in the same folder as the executable, but not otherwise.
UPDATE
It looks as though things are more complicated than I first thought and this doesn't seem to be the issue here - see the comments. The line that's raising the exception is:
externalConfig.AppSettings.Settings["ServerAddress"].Value = serverAddr;
So that means that there's a null reference somewhere along the chain. If you can identify which it is then that should give you a pointer to the problem.
externalConfig.AppSettings.Settings["SSL"].Value = ssl.ToString();
Config file does not contain "SSL"
just my 2c for those that are trying this code.