Search code examples
visual-studioweb-configcompiler-warningssuppress-warnings

Visual Studio - Suppress web.config warning


I have the following, rather irritating, warning appearing my visual studio error list:

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

It originates from web.config. The application compiles fine, I just want to suppress the error.

What doesn't work:

  • Right click > Suppress (it's not an fxcop error)
  • Locating the warning ID in the build window and supressing it via project properties dialog (the warning does not show up in the build window).

Any way to hide this warning, or do I have to live with it?


Solution

  • Solution found. You can update the schema file VS validates again to get rid of the warning. It will only work for your local pc, but if you're anal-retentive about warnings like myself it's worth it.

    • Open up the schema file in visual studio located at:

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

    • Click the link to open the XML Schema Explorer

    • Find the node system.serviceModel\behaviors\endpointBehaviors\behavior and double click it.

    XML Schema Explorer

    This will take you to the offending area in the schema file, which begins with:

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

    Two lines below that, you will see:

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

    Inside that node is where you want to add the offending element. In my case, I added the following: <xs:element name="silverlightFaults"> </xs:element>

    • Save the file, navigate back to web.config and see that the warning is gone.

    Of course, make sure you make a backup of the file before doing this in case anything goes wrong.