473,789 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1632
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.Diagnost ics.Conditional Attribute. It allows to define a routine that
will only be called in a specific build.

<Conditional("D EBUG")> _
Public Sub CalledOnlyInDeb ugBuilds()

End Sub

<Conditional("T RACE")> _
Public Sub CalledOnlyInTra ceBuilds()

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.c om> 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.c om> 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
214
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 model (though I expect to HATE having to actually learn to use it!), but what I can't see is how to define or find #regions in the code. You see, I'd like to put my boilerplate code in regions so that if (when) there is a need to update the code...
6
1864
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
2406
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. What impact do access modifiers have on the order? Also, does anyone use standardised region names?
0
910
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 anybody managed to do it?
7
2737
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
901
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 or a feature, this was very handy.... In VS2005, this "feature" appears to be gone. Is there a new manner of achieving the same function?
6
2382
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) code file from a project, the regions are there again (and collapsed). This is really beginning to annoy me, so I'd really like to find a solution to get rid of these regions. Is there another setting I've missed?
8
1759
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 (blah, blah). Anyone have any suggestions for having regions and their comments show up in XML comments...
1
2375
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 processing toolbox "imagemagick".This program ideally should work on multiple images and gives me the centroids of white/colored dots present in the images. It does this by initially finding out regons that form a dot.It checks for regions whose pixels...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.