Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Cannot restore warning 'warning code' because it was disabled globally
This warning occurs if you use the /nowarn command line option or project setting to disable a warning for the entire compilation unit, but you use #pragma warning restore to attempt to restore that warning. To resolve this error, remove the /nowarn command line option or project setting, or remove the #pragma warning restore for any warnings you are disabling via the command line or project settings. For more information, see the #pragma warning topic.
The following sample generates CS1635:
// CS1635.cs
// compile with: /w:1 /nowarn:162
enum MyEnum {one=1,two=2,three=3};
class MyClass
{
public static void Main()
{
#pragma warning disable 162
if (MyEnum.three == MyEnum.two)
System.Console.WriteLine("Duplicate");
#pragma warning restore 162
}
}