Compiler Error CS0243

The Conditional attribute is not valid on 'method' because it is an override method

The Conditional attribute is not allowed on a method that is marked with the override keyword. For more information, see Knowing When to Use Override and New Keywords (C# Programming Guide).

The compiler never binds to override methods; it only binds to the base method and the common language runtime calls the override, as appropriate.

The following sample generates CS0243:

// CS0243.cs
// compile with: /target:library
public class MyClass
{
   public virtual void M() {}
}

public class MyClass2 : MyClass
{
   [System.Diagnostics.ConditionalAttribute("MySymbol")]   // CS0243
   // remove Conditional attribute or remove override keyword
   public override void M() {}
}

Community Additions

ADD
Show: