Conditional compilation characters not defined

I am having problems with Visual Studio behaving as I expected. I created 2 configuration profiles. One has the FOO symbol, and the other has the BAR symbol. And I have this code:

static class MyClass{
#if FOO
  public static string const MyData="foo defined";
#endif
#if BAR /*yes, I know #elif would work here too.. just trying to be simple*/
  public static string const MyData="bar defined";
#endif
}

and then in another file I have

 if(MyClass.MyData=="foo defined").....

Well, in my application, I get an error that MyClass.MyData is not defined.

In addition, if I have a FOO profile and enter something like #error testafter #if FOO, then it will have a build error, but if I delete it, it will be just fine, and when I go to start I get a compilation error that MyClass does not contains definitions for MyData. It is also an ASP.Net web application.

- , ? , Visual Studio , , - ASP.Net , - ... , ..

: , FOO BAR, , -, MyData.

EDIT2:

, !!! App_Code , .cs, MyClass. , .

#if !(FOO || BAR)
  #error neither foo or bar defined
#endif

, Visual Studio .cs App_Code

+5
1

ASP.NET , . web.config, . : ASP.NET 2.0

+5

All Articles