如何使用System.ServiceModel在关联的配置文件中启用intellisense

Mas*_*low 5 wcf intellisense web-config

我发现所有涉及intellisense的问题似乎都是指自定义配置设置.我试图在.net标准部分上获取intellisense,该部分已从web.config移到service.config中.

有办法吗?

Boz*_*Joe 0

首先你需要有 Visual 2012 或更高版本。这是确保您安装了最新的架构文件和引用。

但主要是关于如何创建根 web.config 或 app.config 文件。

在你的根配置(app.config/web.config)中,你需要指定WCF服务模型关联的配置文件,如下所示

  <system.serviceModel>
    <behaviors configSource="Configuration\behaviors.config"/>
    <bindings configSource="Configuration\bindings.config" />
    <client configSource="Configuration\client.config"/>
    <services configSource="Configuration\services.config" />
  </system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

然后确保您的,例如,bingings.config 文件以行为节点开头

<bindings>
  <basicHttpBinding>
    <binding name="HoHo" messageEncoding="Text">
      <security mode="None"/>
    </binding>
  </basicHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)

使用 configSource 确实可以帮助保持配置文件的可读性。