THESE FORUMS ARE NOW FROZEN
Please choose "Forums" from the Main menu of www.entityspaces.net to get to our new forums.

The configuration is read only

This post has 5 Replies | 1 Follower

Not Ranked
Posts 1
kumaresan Travel [ap] Posted: 03-12-2008 6:44 AM
Code:
1    if (esConfigSettings.ConnectionInfo.Default != "SiteSqlServer")
2 {
3 esConfigSettings ConnectionInfoSettings = esConfigSettings.ConnectionInfo;
4 foreach (esConnectionElement connection in ConnectionInfoSettings.Connections)
5 {
6 //if there is a SiteSqlServer in es connections set it default 7 if (connection.Name == "MyOracleDB1")
8 {
9 esConfigSettings.ConnectionInfo.Default = connection.Name;
10 return;
11 }
12 }

Web.cofig
<EntitySpaces>
<connectionInfo default="MyOracleDB">
<connections>
<add name="MyOracleDB" providerMetadataKey="esDefault" sqlAccessType="DynamicSQL" provider="EntitySpaces.OracleClientProvider" providerClass="DataProvider" connectionString="Persist Security Info=True;User ID=MARTELCALLS;Password=ssa;Data Source=User5;"/>
<add name="MyOracleDB1" providerMetadataKey="esDefault" sqlAccessType="DynamicSQL" provider="EntitySpaces.OracleClientProvider" providerClass="DataProvider" connectionString="Persist Security Info=True;User ID=TEST;Password=ssa;Data Source=User5;"/>
</connections>
</connectionInfo>
</EntitySpaces>
 1.Dynamically  i want to use two database connection 
 2.When i do the change  connection i am getting this error
 Line9: Error:
>The configuration is read only
>Exception Details: System.Configuration.ConfigurationErrorsException: The 
configuration is read only.
 
3.Is this problem from web.config or i need to do any  changes on web.config (means read only like property? if then how?)
4.I can read the config but i can't set the value 
 
  Pls give ur response as soon us possible  
Regards
Kumaresan 


 
 

 
Top 10 Contributor
Posts 3,881

This is enforced by .NET itself. We have a custom configuration section, it does not let you append or change it in any way, however, this is easy. You either have no config file and use our configless support our use the config file for both connections.

You can easily have two connections (or 50) in the ES config area, or just add them all in code. You need to remove both sections from your config file to get rid of this error. 

EntitySpaces | Twitter | BLOG | Please honor our Software License

Top 10 Contributor
Posts 184

FYI: Config sections can be read multiple times, not just when the program loads, and as pointed out, you can create multiple connections within a section.

I do not recommend hard-coding the connections. If you do and you need to make a change, you then must recompile the library and redistribute the .dll. With a config section, the changes can be made and the settings will auto-change upon reloading the application. You can also create routines in your code to force a reload of configuration settings while the application is running. I am not sure about a reloading web config section in ASP .NET, but nothing says you have to use web config. If you read up on .NET configuration sections, you can create you own. Further, .NET supports encrypting config sections too.

 

Top 10 Contributor
Posts 1,675
See "Switching Connections at Runtime" in the FAQ forum.

David Neal Parsons
www.entityspaces.net

Top 500 Contributor
Posts 4

I got the same error.  What I don't think is clear is that you have to remove all references to entity spaces in a config file - both

     <EntitySpaces>
        <connectionInfo default="SQL">
            <connections>
                <add name="SQL" providerMetadataKey="esDefault" sqlAccessType="DynamicSQL" provider="EntitySpaces.SqlClientProvider" providerClass="DataProvider"
                        connectionString="server=dqsqls0140s.devfbr.com\dev;database=EPM;Integrated Security=true" databaseVersion="2000" />
            </connections>
        </connectionInfo>
    </EntitySpaces>

 and

        <sectionGroup name="EntitySpaces" type="EntitySpaces.Interfaces.esConfigSettings, EntitySpaces.Core">
            <section name="connectionInfo" type="EntitySpaces.Interfaces.esConfigSettings, EntitySpaces.Interfaces" allowLocation="true" allowDefinition="Everywhere" restartOnExternalChanges="true"/>
        </sectionGroup>

 Then using the config-less option you will be fine.
 

Top 10 Contributor
Posts 1,675

Sorry. It can be hard for us to look at things with fresh eyes. We sometimes assume things because they are so familiar to us. Currently, under "Configless Execution" in the "Getting Started" PDF, we have:

"You must remove all EntitySpaces sections from the app/web .config file to use configless execution. You cannot use both."

We are open to suggestions. Would this re-wording make things clearer?

"You must remove all EntitySpaces configuration elements from the app/web .config file to use configless execution. Delete the "EntitySpaces" <configSections> entry, and the entire <EntitySpaces>...</EntitySpaces> section. You may still use a config file with EntitySpaces in configless mode. But, it cannot contain any EntitySpaces entries, only the other sections required by your application."

David Neal Parsons
www.entityspaces.net

Page 1 of 1 (6 items) | RSS
Copyright © 2005 - 2009, EntitySpaces, LLC