Mark Lauter
Mark Lauter

Reputation: 877

web.config applicationSettings values not being read from WCF service

I have a WCF service with a setting I created in the WCF application property editor (settings tab).

It has created something like the following property in MySettings class in the Settings.Designer.vb file. Notice the DefaultSettingValueAttribute is set to "This is the OLD value". That's my value for local testing.

<Global.System.Configuration.ApplicationScopedSettingAttribute(),  _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
Global.System.Configuration.DefaultSettingValueAttribute("This is the OLD value")>  _
Public ReadOnly Property Information() As String
  Get
    Return CType(Me("Information"),String)
  End Get
End Property

On the production server I have changed the web.config file as below. The "NEW" value would be useful for the production server. It represents a connection string, or production resource address.

<applicationSettings>        
  <setting name="Information" serializeAs="String">
    <value>This is the NEW value</value>
  </setting>
</applicationSettings>

The problem is after restarting the WCF service (rebooting the server machine completely), it never reads the new value. It continues to use the old value that was set as the default value in the designer file.

I think this must have to do with file permissions, but I don't see anything in the event log that indicates a problem. It's like the WCF service isn't even trying to read the web.config file. I don't find anything like this problem on Google and I've run out of search term ideas.

Why isn't the service reading the settings value from the web.config file?

Upvotes: 2

Views: 2503

Answers (1)

competent_tech
competent_tech

Reputation: 44971

Did you make sure to add the SectionGroup to the ConfigSections of the production web server?

It should look something like:

<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
  <section name="MyWCFService.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>

and your application settings section should look something like:

  <applicationSettings>
    <MyWCFService.My.MySettings>
      <setting name="Information" serializeAs="String">
        <value>This is the NEW value</value>
      </setting>
    </MyWCFService.My.MySettings>
  </applicationSettings>

Upvotes: 2

Related Questions