tags:

views:

221

answers:

2

Hi,

I'm trying to replace the default machine.config settings for the "client" handler with my own handler, however, when i run it, i'm getting this error:

"Section or group name 'client' is already defined. Updates to this may only occure at the configuration level where it is defined."

here is how my app.config looks like:

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

Please let me know if you have any idea why it seems like that it doesn't remove this section (as one would expect) and gives me this error instead.

Thanks.

A: 

AFAIK, you can't do this. The <client> sub-section is strongly tied to the ServiceModelSectionGroup via its Client property.

Drew Marsh
why not? i saw that you can replace other machine.config sections, where does it say that i can't replace it and setting another configurationElement that would list you the endpoints? And if this is the case, is there any way to "proxy" those values from another source (i can't place it in my app.config due to some restrictions).Thanks
Or A
Maybe it would be better if you explained more in your question what it is you're trying to accomplish so we can make a recommendation as to how you can solve the problem.
Drew Marsh
First thank you very much.The problem that we are having is relate to the fact that we can store the WCF channel information in the app.config (for some deployment reasons). Therefore, i thought about creating a "proxy" class that would serve those values (take from another resource) by implementing the configurationSection model and then "override" the "client" (and also services) childs configs with my own implementation which will serve those values to the WCF service (used with TIBCO).please let me know if you have a better idea.
Or A
A: 

You can do this, but you'll have to remove and re-add the entire system.serviceModel section. I don't think you can cherry-pick out just the "client" subsection.

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

It'll be a bit of work, of course. Hopefully this is helpful, but I have a feeling you won't like this answer.

The only way this could work for removing a subsection is if a sectionGroup element supported the <remove> element, which it doesn't: http://msdn.microsoft.com/en-us/library/ms228114.aspx

Hope this was helpful.

Anderson Imes