473,385 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Debug Regions

JZ
Hi,

Is there anyway to mark a block of code so that it will only run in debug
mode?

Like a # debug region ?

Thanks,

--
JZ
Nov 21 '05 #1
4 1620
guy
#If Debug = true then
"JZ" wrote:
Hi,

Is there anyway to mark a block of code so that it will only run in debug
mode?

Like a # debug region ?

Thanks,

--
JZ

Nov 21 '05 #2
guy
#If Debug = true then
'this compiles in debug mode only
#End If

hth
guy

"JZ" wrote:
Hi,

Is there anyway to mark a block of code so that it will only run in debug
mode?

Like a # debug region ?

Thanks,

--
JZ

Nov 21 '05 #3
JZ,
In addition to "#if DEBUG" as the other suggest, check out
System.Diagnostics.ConditionalAttribute. It allows to define a routine that
will only be called in a specific build.

<Conditional("DEBUG")> _
Public Sub CalledOnlyInDebugBuilds()

End Sub

<Conditional("TRACE")> _
Public Sub CalledOnlyInTraceBuilds()

End Sub

If the DEBUG or TRACE conditional compilation constants are not defined
(such as DEBUG in Release builds) the above calls are treated as nops.

Its how Debug.WriteLine & Trace.WriteLine are implemented.

Hope this helps
Jay

"JZ" <jj@anon.anon.com> wrote in message
news:41**********************@news-text.dial.pipex.com...
Hi,

Is there anyway to mark a block of code so that it will only run in debug
mode?

Like a # debug region ?

Thanks,

--
JZ

Nov 21 '05 #4
"JZ" <jj@anon.anon.com> schrieb:
Is there anyway to mark a block of code so that it will only run in
debug mode?

Like a # debug region ?


\\\
#If DEBUG Then
...
#Else
...
#End If
///

In the project properties, make sure the checkbox that defines the
'DEBUG' constant is checked (this checkbox should be checked by default).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Iain | last post by:
I'm part way through a project which will create Data Access classes for SQL Server database more or less automatically from the table definitions in the DB itself. I sort of get the CodeDom...
6
by: C# Learner | last post by:
1) How often do you put regions into your code? a) very often b) occasionally c) infrequently d) never 2) If you didn't answer (d), what do you use regions for? a) hiding ugly code
4
by: Simon | last post by:
Just starting on C# and would like to know what suggestions there are for the order in which declarations, event handlers, properties, private code, nested classes, etc, etc appear in your files....
0
by: G B | last post by:
Hi guys I was wondering whether generating Regions is possible using the CodeDom. I am writing a tool that generates some code and I could not find a way to group code into regions. Has...
7
by: gaidar | last post by:
Hi, everybody, I'm just wondering if someone really need stuff like this: http://msdn2.microsoft.com/library/ms123401.aspx. If you answer yes than explain, please. Thanks! Gaidar
0
by: Sam Marrocco | last post by:
In VS2003, one could instantly close all the #Regions in a code document by clicking the Splitter button in the IDE. It left all the code expanded, but closed only the #Regions areas. Whether a bug...
6
by: Ikke | last post by:
Hi everybody, Can somebody tell me how to disable regions in Visual Studio 2005? I've already told VS not to collapse code to regions in the settings, but each time I open a new (existing)...
8
by: Spleenwort | last post by:
With regard to XML comments in c#. I think that #regions should be self-documenting relative to XML comments or that a <region> tag should be defined and auto-inserted when you type #region...
1
by: sanjeevani | last post by:
Hi guyz, i am new to c++ programming..and this forum ...i just hope that i am giving you all the information which will enable you to figure out the problem. My program uses c++ and image...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.