Fetching connection string from appconfig file in c#

前端 未结 10 1014
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 07:39

I have the following connection string declared in my app.config file:

  
    

        
10条回答
  •  不知归路
    2020-12-19 08:04

    The first syntax is definitely valid.

    The possible cause is that the configuration file is not loaded properly in the application. I want to ensure what type of project it is. If it is a WinForm application or Console application, you need set the in the app.config. It will be compiled to .config and loaded when the application is launched. If it is a Web application, I'm afraid you cannot add the node to app.config, since it will not be loaded. You need to put it in the web.config. In addition, if you want to put the settings in the config file with a .net library (DLL), the configuration file will not be loaded anyway. The configuration file will only follow the main application.

提交回复
热议问题