替换客户端部分不起作用(system.serviceModel)

时间:2009-11-18 23:53:15

标签: wcf app-config

我正在尝试用我自己的处理程序替换“client”处理程序的默认machine.config设置,但是,当我运行它时,我收到此错误:

“已定义了部分或组名'客户'。对此的更新可能仅在定义它的配置级别发生。”

这是我的app.config的样子:

<configuration>
  <configSections>
    <remove name="client"/>
    <sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="client" type="xyz.Messaging.CustomClientSection, Point.Messaging" />
    </sectionGroup>
  </configSections>

如果您知道为什么它似乎没有删除此部分(正如人们所期望的那样),请告诉我。并且反过来给我这个错误。

感谢。

2 个答案:

答案 0 :(得分:0)

AFAIK,你不能这样做。 <client>子部分通过其Client propertyServiceModelSectionGroup密切相关。

答案 1 :(得分:0)

您可以执行此操作,但您必须删除并重新添加整个system.serviceModel部分。我认为你不能只选择“客户”小节。

<configuration>
  <configSections>
    <remove name="system.serviceModel"/>
    <sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="client" type="xyz.Messaging.CustomClientSection, Point.Messaging" />
    </sectionGroup>
  </configSections>
  ...
</configuration>

当然,这将是一项工作。希望这很有用,但我觉得你不会喜欢这个答案。

这可以用于删除子节的唯一方法是,如果sectionGroup元素支持<remove>元素,那么它不会:http://msdn.microsoft.com/en-us/library/ms228114.aspx

希望这有用。