reading from app.config file

后端 未结 8 2393
不知归路
不知归路 2020-11-29 19:34

I am trying to read StartingMonthColumn and CategoryHeadingColumn from the below app.config file using the code

ConfigurationSettings.AppSettings[\"StartingM         


        
8条回答
  •  独厮守ぢ
    2020-11-29 19:57

    The reason is simple, your call to ConfigurationSettings.AppSettings is not returning the required config file. Please try any of the following ways:

    • Make sure your app config has the same name as your application's exe file - with the extension .config appended eg MyApp.exe.config
    • OR you can use ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location).AppSettings["StartingMonthColumn"]

    Hope this helps

提交回复
热议问题