ConfigurationManager return null instead of string values

后端 未结 3 1531
北恋
北恋 2020-12-17 10:50

I am trying to retrieve values from my App.config file which is stored in my working directory, however when I run the program it returns null. I am very confused why this i

3条回答
  •  情歌与酒
    2020-12-17 11:30

    Did you ensure that the config file is placed correctly at the directory from which you're running the application? Is there actually a file called .exe.config in that directory?

    I'm just guessing here - maybe you added the App.Config file in a different project then your exe assembly project...?

    By the way, I copied your code and App.Config as is to a clean project, and this code worked for me. So I'd look in the direction of the config file itself and not in the code. The code is fine...

    Hope this helps,

    Ran

提交回复
热议问题