469,623 Members | 1,498 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

How to determine if you are debugging at runtime

Le
Hi

I would like to know if there was a way to know if you are running in debug or release mode at runtime for VB
This way I could execute certain code when debugging and execute something else in release

Thanks
Le
Jul 21 '05 #1
5 1493
You can use the [Conditional("DEBUG")] Attribute to determine this.
"Le" <an*******@discussions.microsoft.com> wrote in message
news:FC**********************************@microsof t.com...
Hi,

I would like to know if there was a way to know if you are running in debug or release mode at runtime for VB. This way I could execute certain code when debugging and execute something else in release.
Thanks,
Le

Jul 21 '05 #2
Le
Thanks for the reply William, but do you have an example of how to use it

Jul 21 '05 #3
create a function called whatever and add that attribute to it. inside it
call MesageBox.Show("Debug"). In main, call the function. If you build in
debug you'll see a messagebox,otherwise you wont.
[Conditional("Debug")]
private void whatever(){
MessageBox.Show("Debug");
}

in main or wherever, call whatever;
"Le" <an*******@discussions.microsoft.com> wrote in message
news:71**********************************@microsof t.com...
Thanks for the reply William, but do you have an example of how to use it.

Jul 21 '05 #4
Le
Thanks, that worked great
Is there a way to do this on a per line bases or sections of code inside a function or method

Jul 21 '05 #5
That method requires using attributes which must go on subs/functions
properties etc.

you can use your own compiler directiver #if "CONSTANTYOUDEFINED" Check out
Compiler Directives on Google.
"Le" <an*******@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
Thanks, that worked great!
Is there a way to do this on a per line bases or sections of code inside a function or method?

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bob Bamberg | last post: by
reply views Thread by Gary Karasik | last post: by
3 posts views Thread by Developer in California | last post: by
1 post views Thread by mgonzales3 | last post: by
reply views Thread by stimpy_cm | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.