Recently I had an issue where I had to suppress certain errors coming out of ASP.NET configuration files. Since Web.config isn’t a code per se we need to use global suppression file to suppress errors coming out of config file.

The real problem was that the issues where reported not in the project where the file Web.config is located but from a different project in solution:

d:\BuildTest\Any CPU\Release\DeploymentDrop\Web.config(27): warning : CA3114 : Microsoft.Security.Web.Configuration : Always
enable custom errors to return generic error information. Set mode attribute to “On” in unit MyProject file d:\BuildTest\Any CPU\Release\DeploymentDrop\Web.config line 14 column 4 [D:\PathInTFS\MyProject\MyProject.csproj]

The issue was solved by adding GlobalSuppressions.cs to MyProject where there issue was showing up (not where Web.config lives!):

// This file is used by Code Analysis to maintain SuppressMessage 
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given 
// a specific target and scoped to a namespace, type, member, etc.
//
// To add a suppression to this file, right-click the message in the 
// Code Analysis results, point to "Suppress Message", and click 
// "In Suppression File".
// You do not need to add suppressions to this file manually.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security.Web.Configuration", "CA3114:SetCustomErrorsModeToOn")]

Note that SuppressMessage above will suppress all CA3114 messages in the project.