473,382 Members | 1,710 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,382 software developers and data experts.

How to execute in DEBUG only?

37
I want to execute some code only in debug mode. I found this:
Expand|Select|Wrap|Line Numbers
  1. [ Conditional("Debug") ]
  2. public void DebugThis(){...}
  3.  
But this refers for methods. I want to say something like this:

Expand|Select|Wrap|Line Numbers
  1. #if DEBUG
  2.       code...
  3. #endif
  4.  
The code there seems to be commented. What I have to do?

Thank you!
Apr 8 '08 #1
2 1052
Plater
7,872 Expert 4TB
There is a boolean that can tell you if you are running in debug or not.

System.Diagnostics.Debugger.IsAttached

You can use that to control some code, but I don't think there is a way to keep it out of the compile like you could with # directives.
Apr 8 '08 #2
mynkow
37
10x alot. It works for me :)
Apr 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Lyle Fairfield | last post by:
MS-SQL Server utilities Enterprise Manager and Query Analyzer will model almost any MS-SQL object as a simple script file with a default ".sql" extension. But how to "run these files? They are...
8
by: frank | last post by:
Below is some code for doing and insert into one of my tables. The inserts do not work because a duplicate key exists, which I want to happen. The problem is, I cannot get access to return an error...
2
by: Ken Allen | last post by:
I have a service that was developed in C# that I wish to debug. The project resides on my desktop system and I wish it to execute on a remote test system (actually on the next desk). When I...
7
by: Ken | last post by:
Hi guys, this is a curios thing, everything was working fine then I had to restore my development machine( VS.NET, SQL server etc) now I'm receiveing this error from my asp aplication only in...
7
by: Tom | last post by:
How can I make code not execute for a debug build, but do execute for a production build? I have code which prompts for an account and password when the program starts up. It is a pain to have to...
1
by: Lopamudra | last post by:
Hi, I have implemented a HTTPHandler named ThumbnailGenerator.ashx to generate thumbnails for images. I have referenced this within my aspx file in the ImageUrl property of the Img control. When I...
3
by: =?Utf-8?B?QWRpbCBBa3JhbQ==?= | last post by:
I posted this question in vsnet.ide newsgroup about more than a week back but didn't get any single response yet therefore, reposting again same to several newsgroups. When I run my C#...
4
by: HeislerKurt | last post by:
I'm getting the infamous error, "Too few parameters. Expected 2", when executing an update SQL statement in VBA. I assume it's a SQL syntax issue, but I can't find the problem, and I used a VBA...
2
by: rcook349 | last post by:
I'm trying to automate our builds and publishes of our Windows application (deployed to a website via ClickOnce). I'm getting close, I think, on the commands I need to execute. However, how do...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.