0

I have a C# windows application with 4 App Modes - Debug,Pre-Release, Release and UAT. I have to display in the footer of my main form as to what is my current Operating mode. Any idea how I can retrieve the same?

Jessi
  • 5
  • 2
  • 1
    Possible duplicate of http://stackoverflow.com/questions/31496/how-do-i-check-the-active-solution-configuration-visual-studio-built-with-at-run and http://stackoverflow.com/questions/829276/build-configuration-in-c-sharp-code – Dmitry Feb 23 '14 at 23:25

3 Answers3

2

You could use C#'s #if directive http://msdn.microsoft.com/en-us/library/4y6tbswk.aspx

string mode;
#if DEBUG
mode = "DEBUG";
#elseif RELEASE
mode = "RELEASE";
#else
mode = "UAT";
#end

You would also need to set up the symbol in the project file so that the code can pick up on it. You'll find it by selecting the project properties. (Select the project file and press Alt+Enter)

Colin Mackay
  • 18,736
  • 7
  • 61
  • 88
0

Visual Studio doesn't provide for applying the configuration names to your .NET code.

However, you may want to define a custom symbol for each of your configurations in your project build settings and query these symbols in your code, like this:

#if DEBUG
    ...
#elif PRERELEASE
    ...
#elif RELEASE
    ...
#elif UAT
    ...
#endif
AxD
  • 2,714
  • 3
  • 31
  • 53
0

you must use #if reference.

check http://msdn.microsoft.com/tr-tr/library/4y6tbswk.aspx

Onur Gazioğlu
  • 501
  • 2
  • 12