C# Web.Config,system.serviceModel的外部文件

C# Web.Config,system.serviceModel的外部文件,c#,web-config,app-config,configurationmanager,C#,Web Config,App Config,Configurationmanager,使用VS2010 我的web.config中有以下内容(详细信息已删除) 在这个问题中,我参考了汤姆兄弟的第二个答案,这表明了我的想法。 附加 以下是该帖子的配置。有无效的蓝色波浪线 <connectionStrings configSource="web\config\connectionStrings.config" /> <appSettings configSource="web\config\appSettings.config" /> <syste

使用VS2010

我的web.config中有以下内容(详细信息已删除)

在这个问题中,我参考了汤姆兄弟的第二个答案,这表明了我的想法。

附加
以下是该帖子的配置。有无效的蓝色波浪线

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


在这种情况下,如何使用configSource属性?

您不能将
configSource=
应用于
,因为这是一个配置节——而不是一个简单的配置节,
configSource
属性仅在简单的配置节上可用

但是,您应该完全能够将configSource属性应用于
中的任何节点—我一直都在生产系统中这样做—而且它可以正常工作。你真的试过吗

还是你让自己被Visual Studio吓跑了。。。它可能会告诉您(并告诉您)不允许使用
configSource=“…”
(通过那些波浪下划线)-但这只是Visual Studio编辑器中的一个缺点-在
的子节点上,它允许使用
configSource=
属性

您能否(通过编辑原始问题)向我们展示您的示例
serviceModelBehaviors.config
的外观


另外:该文件是否实际位于web应用程序的
web\config
子目录中

您不能将configSource应用于system.serviceModel,因为它是配置节组。您是如何将configSource应用于基础节点的?你能把它包括进来吗?这样我们就可以看到生成错误的配置文件了吗?@David Hoerster:我也没有成功地做到这一点(应用于底层节点)。链接的文章提出了这一点,尽管我无法让它发挥作用。我已经调整了我的帖子以显示该帖子的答案。是的,这确实是VisualStudio的一个失败。因此,如果您使用此选项,您将不得不忍受VS中的永久警告。Visual Studio 2010告诉我,
绑定
客户端
系统的子元素也“不允许”使用configSource;就我所见,Visual Studio 2010编辑器是错误的。我仍然在VS2012上看到这一点。我仍然在VS2013中看到这一点。并且刚刚在VS2013中检查。VS2015中也有同样的警告。去微软!
The 'configSource' attribute is not allowed
<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>