9

I use:

[Obsolete("Use AnotherMethod() insted.", false)]

2nd parameter is false but Visual Studio shows Warning as Error for every obsolete method call preventing project from compilation. How to make VS mark these calls as Warning not Error?

Sergey Metlov
  • 25,747
  • 28
  • 93
  • 153
  • 1
    Check this answer [http://stackoverflow.com/questions/2520853/warning-as-error-how-to-rid-these][1] [1]: http://stackoverflow.com/questions/2520853/warning-as-error-how-to-rid-these – empi Apr 30 '12 at 08:57
  • Not a solution of my problem. In that answer is suggested to disable warnings at all but I need to disable only for `Obsolete`. – Sergey Metlov Apr 30 '12 at 08:59
  • 2
    Then simply said: there is no solution. Obsolete warning, warning as error -> vs blows with error. Simple logic for beginners. – TomTom Apr 30 '12 at 09:00
  • 1
    Did you tiry this solution? [Link][1] [1]: http://stackoverflow.com/questions/5275072/how-to-ignore-compiler-warning-when-using-obsolete-attribute-on-a-class-used-wit – Anton Sizikov Apr 30 '12 at 09:00
  • 1
    @DotNETNinja Check this out ,suits you better in my case http://stackoverflow.com/questions/968293/c-sharp-selectively-suppress-custom-obsolete-warnings – V4Vendetta Apr 30 '12 at 09:00

1 Answers1

8

On the obsolete method define:

#pragma warning disable 0618
        [Obsolete("test",false)]
        private void myMethod()

then go to project properties, under build, in suppress warning type type 0618, Now it will ignore that particular method and project will compile

Habib
  • 219,104
  • 29
  • 407
  • 436