[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

The configuration is read only.

Posted on 2006-06-13
3
Medium Priority
?
3,392 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 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