/warnaserror (Treat Warnings as Errors)
This documentation is archived and is not being maintained.

/warnaserror (Treat Warnings as Errors)

/warnaserror[+ | -]


The /warnaserror+ option treats all warnings as errors. Any messages that would ordinarily be reported as warnings are instead reported as errors, and the build process is halted (no output files are built).

By default, /warnaserror- is in effect, which causes warnings to not prevent the generation of an output file. /warnaserror, which is the same as /warnaserror+, causes warnings to be treated as errors.

Use /warn to specify the level of warnings that you want the compiler to display. Use /nowarn to disable certain warnings.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C# Project Properties.
  2. Click the Configuration Properties folder.
  3. Click the Build property page.
  4. Modify the Treat Warnings As Errors property.

To set this compiler option programmatically

See TreatWarningsAsErrors Property.


Compile in.cs and have the compiler display no warnings:

csc /warnaserror in.cs

See Also

C# Compiler Options

© 2016 Microsoft