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?
system. serviceModel is a root element of all WCF configuration elements. The configuration information for a service is contained within a system.
Starting with . NET Framework 4, WCF comes with a new default configuration model that simplifies WCF configuration requirements. If you do not provide any WCF configuration for a particular service, the runtime automatically configures your service with default endpoints, bindings, and behaviors.
Let us examine how to setup binding for an endpoint in the web. config file. Step 1: Choose basicHttpBinding as a value in the binding attribute of an endpoint. Step 2: This step is optional and is only required if the binding's default properties need to be modified, as shown in the example below.
configuration.svcinfo: Contains a snapshot of the configuration generated for the client service endpoint for the local (app|web).config. configuration91. svcinfo: For each property in config, contains an XPath to the setting and the original value stored in config.
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??
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With