C# Configuration Files

后端 未结 5 1939
说谎
说谎 2021-02-03 14:58

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

5条回答
  •  执笔经年
    2021-02-03 15:52

    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.

提交回复
热议问题