?
Solved

The configuration is read only.

Posted on 2006-06-13
3
Medium Priority
?
3,385 Views
Last Modified: 2007-11-27
I am trying to use the following code to add a connection string to the web.config at runtime.  I got an error says "The configuration is read only."  Any ideas?  

         Dim conn As New ConnectionStringSettings
         conn.ConnectionString = "Data Source=xx;Persist Security Info=True;User ID=xx;password=xx;"
         conn.Name = "myConn"
         conn.ProviderName = "System.Data.OracleClient"
         ConfigurationManager.ConnectionStrings.Add(conn)

I am using Visual Studio 2005.   I am developing a web app.    Thanks!
0
Comment
Question by:tz478
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
existenz2 earned 2000 total points
ID: 16894187
The default configuration files are meant to be read only by (good) design. If you want to save additional information you need to use resource files or custom config files together with custom classes which read/write the config files.
0
 
LVL 1

Author Comment

by:tz478
ID: 16894649
The above code comes from Wrox "Professional ASP.NET 2.0" Chapter 11 P351.  They did not mention anything about read only.

Well, I guess I have to take your word - the web.config is read only by design.  Thanks!
0
 
LVL 14

Expert Comment

by:existenz2
ID: 16895962
I had another look at it when you mentioned 2.0, I assumed you were using 1.1 (my bad, should have known that considering the code you posted), and although I still stick to my point that you should threat the web.config as a read only file, in .NET 2.0 you are able to read/write data into the appsettings and connectionString tags inside the web.config. It has big cons.

You can do this with (some examples):
http://www.dotnetspider.com/qa/Question42231.aspx
http://msdn2.microsoft.com/en-us/system.web.configuration.webconfigurationmanager.aspx
http://www.developersdex.com/asp/message.asp?p=1116&r=5053428
http://www.odetocode.com/Articles/418.aspx

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question