【问题标题】:Visual Studio - Suppress web.config warningVisual Studio - 禁止 web.config 警告
【发布时间】:2012-04-22 01:22:56
【问题描述】:

我的 Visual Studio 错误列表中出现了以下相当烦人的警告:

The element 'behavior' has invalid child element 'silverlightFaults'. List of possible elements expected: 'clientVia, callbackDebug, callbackTimeouts, clear, clientCredentials, transactedBatching, dataContractSerializer, dispatcherSynchronization, remove, synchronousReceive, enableWebScript, webHttp, endpointDiscovery, soapProcessing'.

它源自 web.config。应用程序编译正常,我只是想抑制错误。

什么不起作用:

  • 右键单击 > 抑制(这不是 fxcop 错误)
  • 在构建窗口中找到警告 ID 并通过项目属性对话框将其抑制(警告不会显示在构建窗口中)。

有什么方法可以隐藏这个警告,还是我必须忍受它?

【问题讨论】:

    标签: visual-studio web-config compiler-warnings suppress-warnings


    【解决方案1】:

    找到解决方案。您可以更新模式文件 VS 再次验证以消除警告。它仅适用于您的本地电脑,但如果您对像我这样的警告保持警惕,那么它是值得的。

    • 在位于以下位置的 Visual Studio 中打开架构文件:

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas\DotNetConfig.xsd

    • 点击链接打开 XML Schema Explorer

    • 找到节点 system.serviceModel\behaviors\endpointBehaviors\behavior 并双击它。

    这会将您带到架构文件中的违规区域,该区域以:

    <xs:element name="behavior" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior">

    下面两行,你会看到:

    <xs:choice minOccurs="0" maxOccurs="unbounded">

    在该节点内是您要添加违规元素的位置。就我而言,我添加了以下内容: <xs:element name="silverlightFaults"> </xs:element>

    • 保存文件,导航回 web.config 并查看警告已消失。

    当然,请确保在执行此操作之前对文件进行备份,以防出现任何问题。

    【讨论】:

    • 有没有办法将架构添加到我使用的解决方案中,以便我们可以将其添加到源代码管理中?
    猜你喜欢
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    • 2013-06-02
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 1970-01-01
    相关资源
    最近更新 更多