SqlConfigurationSource problem

Topics: Building and extending application blocks, Enterprise Library Core, General discussion
May 26, 2009 at 10:16 AM

Hi,

I'm using SqlConfigurationSource. I am facing a problem when using SqlConfigurationSource with Ent. Lib. Configuration Console.

If you open a .config file with the console and update any of the SqlConfigurationSource properties, then it won't use the updated properties. It just saves them to the file, but won't use it.

for example, if you update SetStoredProcedure propoerty and click save. It will save the updated value in the app.config file but it won't use the new stored procedure for this session. Any idea? Am I missing something obvious? :)

 

Also, I am using WCF in my project. My app.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
  </configSections>
  <enterpriseLibrary.ConfigurationSource selectedSource="Sql Configuration Source">
    <sources>
      <add name="Sql Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.SqlConfigurationSource.SqlConfigurationSource, Microsoft.Practices.EnterpriseLibrary.SqlConfigurationSource, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        connectionString="[ConnString]"
        getStoredProcedure="[SP]"
        setStoredProcedure="[SP]"
        refreshStoredProcedure="[SP]"
        removeStoredProcedure="[SP]"
/>
      <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
    </sources>
  </enterpriseLibrary.ConfigurationSource>
  <system.serviceModel>
    <bindings>
      <netMsmqBinding>
        <binding name="NetMSMQBinding" exactlyOnce="false">
          <security>
            <transport msmqAuthenticationMode="None" msmqProtectionLevel="None" />
          </security>
        </binding>
      </netMsmqBinding>
    </bindings>
    <client>
      <endpoint address="net.msmq://localhost/private/LogQueue_WCFNetMsmq" binding="netMsmqBinding" bindingConfiguration="NetMSMQBinding" contract="Tieto.HCW.HCFLib.WCFService.IQueuingMessageContract" name="NetMSMQEndPoint" />
    </client>
  </system.serviceModel>
</configuration>

 

So the problem is SqlConfigurationsource doesnot recognise the <system.serviceModel>... </system.serviceModel> section. So this does not go to the database. Is there a way to save this section to database using SqlConfigurationSource.

Thanks,

Andy

May 26, 2009 at 10:55 AM

Hi Andy, I'm currently looking into this, see if I can repro  your case.  I'll let you know what I can find out.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 26, 2009 at 11:13 AM

Hold on, how does your slqconfiguration source relates to your system.servicemodel section?  I can't see it in your config file.  So which is the real problem?  The sqlconfiguration source not using the updated value or the one which has something to do with the system.servicemodel section?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 26, 2009 at 12:17 PM

Hi Sarah,

Thanks for the reply. Actually those two are the different problems.

To repro the first problem, just open the your app.config that uses SqlConfigurationSource in the Ent. Lib. Configuration Console.

Then update any property like stored procedure names or connection string and hit the save button. It won't use those updated properties. It uses the values it got when you first opened the app.cofig.

Even if I give the wrong connection string it won't give me error, because it has, may be, cached the connection string while opening the app.config.

 

And the second problem is regarding SqlConfigurationSource not recognising the non-Ent. Lib. sections like system.servicemodel section. So these non-Ent. Lib sections are not stored in the database.

So is there any way to make SqlConfigurationSource understand and store theses sections into the database.

 

Thanks,

Andy

May 27, 2009 at 12:35 PM

after changing or updating some properties in the sql config source, did you verfied that after the change it was commited to the config file? What I tried doing is changing the connection string then save it. but after a run it uses the updated connection string and throws exception because I put a connection string that does not exist. Do you have anymore pointers to repro you first problem? On you're second problem, we are still trying to find an answer for this.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 28, 2009 at 8:34 AM
Edited May 28, 2009 at 8:34 AM

Hi,

Thanks for the reply. Yes the changes are committed to the local file. But, the configuration console does not use the updated properties while saving settings to the database.

Here are the steps to reproduce the behaviour:

 

1. Open a .config file that uses SqlConfiguraionSource or create a new one give the proper values to connectionString, and stored procedures

2. Hit the Save button. As all properties have valid values, it should save the settings to the database.

3. Now update the property SetStoredProcedure. Give a wrong stored procedure name that does not exist.

4. Hit the save button again. It will store the updated to value to app.config file, but it will NOT use this updated value while saving the settings to the database. It will use the old one.

It does not give you any error like stored procedure doesn't exist...

May be, the configuration console caches the properties when you open app.cofig or create it for the first time (!?).

Let me know if you are able to reproduce the behaviour.

 

Thanks,

Andy

May 28, 2009 at 9:03 AM
Edited May 28, 2009 at 9:18 AM

We're not able to repro the behavior.  We could send you the sample test project we are running, maybe you could also send yours so we could compare.

Regarding the system,servicemodel section,  I think you have to make EntLib know about that configuration element, the concept is the same as with Environmental Overrides.  See this thread - http://entlib.codeplex.com/Thread/View.aspx?ThreadId=30437.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 28, 2009 at 9:35 AM

Hi,

It would be great if you could send me the sample test project. Here is my email address: andycr7@gmail.com.

 

Thanks,

Andy

May 28, 2009 at 9:40 AM
Edited May 28, 2009 at 9:53 AM

Done sending.

Actually, in answer again to your second question about saving the system.servicemodel in the database,  I found a patch for it by Alois Kraus - http://geekswithblogs.net/akraus1/articles/75391.aspx

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 28, 2009 at 11:03 AM

Hi,

Thanks for sending the sample application.

Actually that is not the way to reproduce the behaviour. You need to use Enterprise Library Configuration Console to reproduce it.

Here are the steps to reproduce it:

1. Open the app.config file from your sample application with Enterprise Library Configuration Console. It will show you all the settings from the database.

2. Do not close the Enterprise Library Configuration Console. Now update the property SetStoredProcedure. Give a wrong stored procedure name that does not exist.

    Actually you can try modifying any other property e.g. you can give wrong connection string.  Please make sure you are modifying these settings with the Enterprise Library Configuration Console.

3. Hit the save button again. It will store the updated to value to app.config file (even if you have given the wrong procedure name or wrong connection string), but it will NOT use this updated value while saving the settings to the database. It will use the old one.

Only thing is the Enterprise Library Configuration Console saves these values to the app.config correctly, but it won't use them in the same session when storing to the database.

 

Thanks,

Andy

May 28, 2009 at 12:01 PM

I'll try again but are you saying you modify the configuration while the program is running? 

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 28, 2009 at 12:14 PM

Hi,

It has nothing to do with the program. It is about  Enterprise Library Configuration Console and your app.config.

I have given the exact steps in my previous reply. You just need to open the app.config of the sample test project you had sent me earlier with Enterprise Library Configuration Console and follow the steps given in my previous reply. You don't need any coding to reproduce the behavior. Just Enterprise Library Configuration Console and a sample app.config.

Let me know if you understood what I'm trying to say. Otherwise I will send a document with screenshots.

Thanks,

Andy

May 28, 2009 at 12:25 PM
Edited May 28, 2009 at 12:26 PM

Sorry about that.  I see now, I was able to reproduce the error.  I'll look into the source code and see what's causing this behavior.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 28, 2009 at 1:19 PM

Seems like the SqlConfigurationData is only initialized during opening of the config tool and that value is being used until you close the tool.  We'll verify this with the EntLib team if this is a design decision.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 8, 2009 at 12:34 AM

We are redesigning the config tool for V5 anyway and we will take this into account.

Thanks,
Grigori