469,271 Members | 954 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Way to tell if in debug mode

Is there a property or method to tell you if you are running in the IDE
or as a compiled exe? Thanks.

Nov 16 '05 #1
6 28201
Do a check against System.Diagnostics.Debugger.IsAttached.
If it's true than a debugger is attached, otherwise not.
-----Original Message-----
Is there a property or method to tell you if you are running in the IDEor as a compiled exe? Thanks.

.

Nov 16 '05 #2
You can tell in wich configuration your code is compiled by compiler
directives:

#if DEBUG
//Add code here
#else
//add code here
#endif

you can set the soulution configuration (DEBUG/RELEASE) in the Project
Property Pages, Configuration Manager.

This is not exactly an answer to your question. The executed code is the
same as compiled .exe and in the IDE. But you can make a difference to your
debug version and release version.

I hope this helps
"Marty" wrote:
Is there a property or method to tell you if you are running in the IDE
or as a compiled exe? Thanks.

Nov 16 '05 #3
The System.Diagnostics.Debugger.IsAttached property will indicate whether a
debugger is attached to your process. However, the VStudio IDE is not the
the only possible debugger. Are you perhaps more interested in whether your
component is being used in design mode within the IDE?

"Marty" <ma********@absu.accenture.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Is there a property or method to tell you if you are running in the IDE
or as a compiled exe? Thanks.

Nov 16 '05 #4
Yes, knowing if I am in design mode would be perfect.

Nov 16 '05 #5
If this is a Windows Forms component, you can use the DesignMode property of
any type that inherits from System.ComponentModel.Component (which most
controls and forms do). For an ASP.NET control, you should instead check if
there is an HttpContext. i.e.: <in design mode> = (HttpContext.Current ==
null).

HTH,
Nicole
"Marty" <ma********@absu.accenture.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Yes, knowing if I am in design mode would be perfect.

Nov 16 '05 #6
Hello

Our approach (windows forms app):

public static bool IsDesignMode()
{
return (Application.ExecutablePath.ToLower().IndexOf("dev env.exe")
!= -1) ;
}

When you have executable name you can do it in a similar way.

Aleksandar

"Marty" <ma********@absu.accenture.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Is there a property or method to tell you if you are running in the IDE
or as a compiled exe? Thanks.

Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Greg Smith | last post: by
1 post views Thread by rob | last post: by
12 posts views Thread by nospam | last post: by
12 posts views Thread by Micah | last post: by
6 posts views Thread by Rene | last post: by
6 posts views Thread by pauldepstein | last post: by
3 posts views Thread by corey.hutchinson | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.