narasiman rao

narasiman rao

  • NA
  • 519
  • 769.1k

Configuration system failed to initialize

Aug 24 2016 3:58 AM
  App.config code as follows
 
In Appconfig code as follows  
 <?xml version="1.0" encoding="utf-8"?>  
 <configuration>  
   <startup>      
   <supportedRuntime version="v4.0" sku="NETFramework,Version=v4.5"/>  
  </startup>  
 <configSections> 
   <section name="dataConfiguration"; type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/> 
</configSections>  
<connectionStrings> 
<add name="OneTransportConnectionString" providerName="System.Data.SqlClient" connectionString="server=One\Others;database=OneC768;user id=On998;password=988;Max pool size = 25;Min pool size = 0"/>
 </connectionStrings>  
</configuration>
Program.cs page code as follows                 
 string connectionString = ConfigurationManager.ConnectionStrings["OneTransportConnectionString"].ConnectionString;   
          SqlConnection sqlConnection = new SqlConnection(connectionString);              
 SqlCommand cmd = new SqlCommand();       
SqlDataReader reader;         
    cmd.CommandText = "Select * from Customers";   
          cmd.CommandType = CommandType.Text;      
       cmd.Connection = sqlConnection;         
    sqlConnection.Open();           
  reader = cmd.ExecuteReader();      
       Console.WriteLine("test");    
         sqlConnection.Close();
When i run the above code shows error as follows

Configuration system failed to initialize

The above error code in below line as follows

string connectionString = ConfigurationManager.ConnectionStrings[&quot;OneTransportConnectionString&quot;].ConnectionString;

please help me what is the mistake in my above code



Answers (2)