Val*_*mas 19 c# configurationmanager app-config web-config
使用VS2010
我在web.config中有以下内容(删除了详细信息).
<system.serviceModel>
<behaviors />
<services />
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<bindings />
<client />
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我想使用属性configSource,就像appSettings可以用来从另一个配置文件中获取这些元素的细节一样.
我试图将configSource属性应用于system.serviceModel或每个子节点.但是,我得到了无效的蓝色线条说:
The 'configSource' attribute is not allowed
Run Code Online (Sandbox Code Playgroud)
我在这个问题中提到了第二个答案(汤姆兄弟),这个问题展示了我想要的东西.
web.config可以从外部xml文件中读取吗?
附加
以下是该帖子的配置.有无效的蓝色波浪线.
<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>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,如何使用configSource属性?
mar*_*c_s 29
您无法申请configSource=,<system.serviceModel>因为这是一个配置节组 - 而不是一个简单的配置节,该configSource属性仅适用于简单的配置节.
但是,您应该绝对能够将configSource属性应用于内部的任何节点<system.serviceModel> - 我一直在生产系统中执行此操作 - 它只是起作用.你有没有尝试过?
或者你是否让自己被Visual Studio吓跑了......它可能会告诉你(并告诉你)configSource="...."不允许的(通过那些波浪下划线) - 但这只是Visual Studio编辑器中的一个缺点 - 在子节点上<system.serviceModel>,它被允许有一个configSource=属性!
你能告诉我们(通过编辑你的原始问题)你的serviceModelBehaviors.config例子是什么样的吗?
另外:该文件是否在物理上位于web\configWeb应用程序的子目录中?
| 归档时间: |
|
| 查看次数: |
12552 次 |
| 最近记录: |