Decrease Font Size
Increase Font Size

ASP.NET windows application - detecting debug mode

Today, I was working on one of the windows application and at one point I need to figure out if the application is running on the Debug mode or Release mode.

We can use HttpContext.Current.IsDebuggingEnabled for the web applications.

As for the Windows Application, Initially I was using the code below

 internal static bool DebugMode()
            bool isDebugMode = false;
//Application.StartupPath will give me the path for the executable file that started the application
            if (Application.StartupPath.Contains(@"\bin\Release")) //it will be \bin\Debug if we running on Debug Mode
                isDebugMode = false;

            return isDebugMode;


But then I found this piece of code, which I think is cool because I never thought about this approach




 internal static bool IsDebug
            #if DEBUG
                get{ return true;}
                get { return false; }


Comments (8) -

  • wisata ciamis

    6/5/2009 9:13:32 AM |

    The template of this blog is quite good, and I think the score of this blog is 8.7 and I will vote for you in Blogs Choice Awards

  • admin

    6/6/2009 1:38:11 AM |

    Thanks Smile

  • regcure review

    10/12/2009 3:11:13 AM |

    Helpful tip, thank you

  • traslochi milano

    10/28/2009 10:13:26 AM |

    Thanks for sharing this powerful information.That's very helpful and interesting.

  • Melayu Boleh

    11/17/2009 2:27:48 AM |

    Excellent read. Very insightful. I'm kind of new to the world of blogging, this will definately help.

  • application hosting

    1/28/2010 8:14:39 PM |

    I’m impressed, you know what you’re talking about

  • meilleures pages de casino en ligne

    2/24/2010 3:07:11 AM |

    I will recommend my friends to read this.I will bookmark your blog and have my children check up here often.I am quite sure they will learn lots of new stuff here than anybody else!....

  • Steve

    3/11/2010 9:35:56 AM |

    This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work.

Add comment