Web.Config, external file for system.serviceModel

14,040

You cannot apply configSource= to <system.serviceModel> since that is a config section group - not a simple config section, and the configSource attribute is only available on simple configuration sections.

You should however absolutely be able to apply the configSource attribute to any of the nodes inside <system.serviceModel> - I do this all the time, in production systems - and it just works. Have you even really tried??

Or did you let yourself be scared off by Visual Studio... it might show you (and tell you) that configSource="...." is not allowed (by those wavy underlines) - but that's just a shortcoming in the Visual Studio editor - on the child nodes of <system.serviceModel>, it is allowed to have a configSource= attribute!

Can you show us (by editing your original question) what your e.g. serviceModelBehaviors.config looks like??

Also: is that file physically in the web\config subdirectory of your web application??

Share:
14,040

Related videos on Youtube

Valamas
Author by

Valamas

Updated on February 16, 2020

Comments

  • Valamas
    Valamas over 4 years

    Using VS2010

    I have the following in my web.config (detail removed).

    <system.serviceModel>
        <behaviors />
        <services />
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
        <bindings />
        <client />
    </system.serviceModel>
    

    I would like to use attribute configSource the same as appSettings can use to get the detail of these elements from another config file.

    I have tried to apply configSource attribute to either system.serviceModel or to each of the sub nodes. However, I get the invalid blue wavvy line saying:

    The 'configSource' attribute is not allowed
    

    I refer to the second answer (by Tom Brothers) in this question which demonstrates what I would like.
    Can a web.config read from an external xml file?

    Additional
    Here is the configuration from that post. Has invalid blue wavvy lines.

    <connectionStrings configSource="web\config\connectionStrings.config" /> 
    <appSettings configSource="web\config\appSettings.config" /> 
    <system.diagnostics configSource="web\config\diagnostics.config" /> 
    <system.serviceModel> 
        <bindings configSource="web\config\serviceModelBindings.config" /> 
        <behaviors configSource="web\config\serviceModelBehaviors.config" /> 
        <services configSource="web\config\serviceModelServices.config" /> 
        <client configSource="web\config\serviceModelClient.config" /> 
    </system.serviceModel> 
    

    How can I use the configSource attibute in this case?

    • David Hoerster
      David Hoerster about 13 years
      Well, you can't apply configSource to system.serviceModel since it's a config section group. How did you apply configSource to the underlying nodes? Can you include what that looks like so we can see the config file that's generating the errors?
    • Valamas
      Valamas about 13 years
      @David Hoerster: I have not been successful with that either (applying to underlying nodes). The linked article suggests it, although I cannot get it to work. I have adjusted my post to show the answer from that post.
    • Abacus
      Abacus almost 11 years
      Yes, it is indeed a failing of Visual Studio. So you will have to live with permanent warnings in VS if you use this.
  • Jez
    Jez over 10 years
    I get Visual Studio 2010 telling me that configSource is "not allowed" for my bindings and client child elements of system.serviceModel, too; as far as I can see, the Visual Studio 2010 editor is just wrong.
  • gverdouw
    gverdouw over 10 years
    I still get this on VS2012 too
  • Dr Rob Lang
    Dr Rob Lang over 10 years
    Still getting this in VS2013.
  • Dr Rob Lang
    Dr Rob Lang over 10 years
    And just checked in VS2013.
  • SubliemeSiem
    SubliemeSiem over 7 years
    Same warning in VS2015. Go microsoft!
  • Bildsoe
    Bildsoe about 7 years
    Also getting it in VS2013 - and I'm not able to build my solution - no errors showing in the ErrorList
  • Anderson Pimentel
    Anderson Pimentel over 6 years
    Same warning on VS2017 (v. 15.3.5)
  • ignotus
    ignotus over 3 years
    Same warning on VS2019 yaay