Disable Warnings In VS2005

How To Disable Any Specific Warning in VS 2005
VS 2005 generates many types of compile warnings. The most annoying ones are those underlined directly in the source code (all in VB .NET). We cannot get rid of all warnings. For example, our VSdocman allows XML comments also for namespaces. VS doesn’t like this and gives the following warning:

XML comment block cannot be associated with any language element that supports the application of XML documentation comments. XML comment will be ignored.

In VB .NET, when we go to project Properties – Compile tab, we can change the behaviour of some warnings. We can set the notification to Error, Warning or None. But we can change only limited set of warnings. So how can we set our custom warning?

It’s quite easy in C#. We can enter comma delimited list of warning IDs in project Properties – Build tab, Errors and warnings section. In VB .NET, we must use small trick described later.

And how can we get the ID for specific kind of warning? This information is not present in Error list window. We must open Output window and build the project. Warnings use the full format including the ID in output window. In our case we get:

BC42312: XML comment block cannot be associated with any language element that supports the application of XML documentation comments. XML comment will be ignored.

The ID is just numeric part, in our case 42312. As already mentioned, we can directly enter this value in project properties window in C#.

For VB .NET we need to manually edit project .vbproj file.

Close VS.
Open .vbproj file. Find tag and add the ID there. In our case it may look like 42312. Don’t place any whitespaces and newlines in this tag! There is one section for each configuration (Release/Debug) so you need to edit all of them.
Save the .vbproj file and open VS.
After this, you shouldn’t get specified warnings during the build nor should you see warning underline during editing.

Advertisements

%d bloggers like this: