web.config applicationSettings值未从WCF服务读取

时间:2011-12-06 23:20:07

标签: vb.net wcf

我有一个WCF服务,其中包含我在WCF应用程序属性编辑器(设置选项卡)中创建的设置。

它在Settings.Designer.vb文件中的MySettings类中创建了类似以下属性的内容。请注意,DefaultSettingValueAttribute设置为“This is the OLD value”。这是我对本地测试的价值。

<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

在生产服务器上,我更改了web.config文件,如下所示。 “NEW”值对生产服务器很有用。它表示连接字符串或生产资源地址。

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

问题是在重新启动WCF服务(完全重新启动服务器计算机)后,它永远不会读取新值。它继续使用在设计器文件中设置为默认值的旧值。

我认为这必须与文件权限有关,但我在事件日志中没有看到任何表明存在问题的内容。这就像WCF服务甚至没有尝试读取web.config文件。我在谷歌上找不到类似这个问题的东西,而且我已经没有了搜索术语的想法。

为什么服务没有从web.config文件中读取设置值?

1 个答案:

答案 0 :(得分:2)

您确定将SectionGroup添加到生产Web服务器的ConfigSections吗?

它应该类似于:

<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>

,您的应用程序设置部分应如下所示:

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