Decrease Font Size
Increase Font Size
   BLOG

ASP.NET windows application - detecting debug mode

by Admin 27. June 2009 21:40

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

from http://www.west-wind.com/WebLog/posts/10228.aspx

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

Tags: , ,

ASP.NET

Comments

6/24/2009 3:13:32 AM #

wisata ciamis

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

wisata ciamis United Kingdom

6/24/2009 7:38:11 PM #

admin

Thanks Smile

admin United States

10/30/2009 9:11:13 PM #

regcure review

Helpful tip, thank you

regcure review United States

11/16/2009 4:13:26 AM #

traslochi milano

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

traslochi milano United States

12/5/2009 8:27:48 PM #

Melayu Boleh

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

Melayu Boleh Australia

2/16/2010 2:14:39 PM #

application hosting

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

application hosting United States

Add comment


(Will show your Gravatar icon)

  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading