Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

Is there is a way in WPF (C#) to find Weather the application is running in Dubug mode or Release Mode.
Posted

C#
if (System.Diagnostics.Debugger.IsAttached)
  {
           // Do this
  }
  else
  {
            // Do that
  }



or

C#
#If DEBUG Then 
    Console.WriteLine("Debug mode.") 
#Else 
    Console.WriteLine("Release mode.") 
#End If 



Make sure that the option "Configuration settings" -> "Build" "Define DEBUG constant" in the project properties is checked.

or


#If CONFIG = "Debug" Then
  'do somtehing
#Else
  'do something else
#EndIf
 
Share this answer
 
#if DEBUG
Console.WriteLine("Mode=Debug");
#else
Console.WriteLine("Mode=Release");
#endif

OR better still

C#
[Conditional("DEBUG")]
void PrintLog() {
    Console.WriteLine("Debug info");
}

void Test() {
    PrintLog();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900