The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

The configuration is read only

Last post 05-21-2008, 11:42 AM by David.Parsons. 5 replies.
Sort Posts: Previous Next
  •  03-12-2008, 6:44 AM 8388

    Travel [ap] The configuration is read only

    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 


     
     

     
  •  03-12-2008, 7:13 AM 8389 in reply to 8388

    Re: The configuration is read only

    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
  •  03-12-2008, 9:43 AM 8392 in reply to 8389

    Re: The configuration is read only

    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.

     

  •  03-12-2008, 11:38 AM 8393 in reply to 8388

    Re: The configuration is read only

    See "Switching Connections at Runtime" in the FAQ forum.
    David Neal Parsons
    www.entityspaces.net
  •  05-21-2008, 6:38 AM 9396 in reply to 8388

    Re: The configuration is read only

    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.
     

  •  05-21-2008, 11:42 AM 9403 in reply to 9396

    Re: The configuration is read only

    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
View as RSS news feed in XML