A practical guide to.NET configuration file

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

  I think all of the configuration file will not be unfamiliar, in most of the projects will be used it, then give some practical example configuration file.

     Store the connection string using the XML format of configuration file, reading and Reflection Technology.

using System.Reflection;

String str = ConfigurationManager.AppSettings["DemoKey"].Value;

     The program system.NET to read the config file in the computer configuration is full range, if two config files have the same name but different key words, the program will load the configuration error occurred in

using System.Configuration;

string conStr=ConfigurationManager.ConnectionStrings["SqlConStr"]. ConnectionString.ToString();



  <startup useLegacyV2RuntimeActivationPolicy ="true ">

requiredRuntime safemode ="true " imageVersion ="v4.0 " version ="v4.0 "/>

supportedRuntime version ="v4.0 " sku ="client " />




<startup useLegacyV2RuntimeActivationPolicy="true">

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>




The web version of.Net is set to 4, otherwise unable to configure.

    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime requestValidationMode="2.0"/>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Ellen at November 14, 2013 - 8:18 PM