asp.net - Reading config file without Configuration section -
Asked for a little embarrassment, but since I did not have to do this, it goes here I have a config The file contains the connection string for the app stored in this format.
& lt; ConnectionStrings & gt; & Lt; Clear /> & Lt; Add name = "MyConnectionStringName" connectionString = "{here is a connection string}" /> & Lt; / ConnectionStrings & gt;
I tried the configuration manager but it requires that "configuration" is the basic element in the file, is there something else in the configuration name space, or should I just use LinqToXml?
Update: I can not change anything in the file, the file is already already in use for some years of home framework. All content in the file is shown above
Update 2: The second format reveals that this file is referenced from the app.center
& lt; ConnectionStrings configSource = "Config \ connectionstrings.config" />
which allows me to use the configuration manager.
The Connection Connection section is more for just one configuration file. If you are using Visual Studio, an easy way to fix your problem Using IDE to add a new application configuration file IDE will create a shell file for you, which you can add to your connection section (Configuration in Section).
With the help of the least, you need it:
& Lt; Add name = "MyConnectionStringName" connectionString = "{connection string}" /> & Lt; / ConnectionStrings & gt; & Lt; / Configuration & gt;
Comments
Post a Comment