473,405 Members | 2,421 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,405 software developers and data experts.

Release Mode Compiling with System.Diagnostics.Debug

Suppose that you have below property in some class,
#if DEBUG
public string DebugInfo
{
get
{
return "INDEX : " + _name + "\n" +
"Index Owner : " + _owner.Name + "\n" +
"Index Column Count: " + _columns.Count + "\n";
}
}
#endif

Somewhere you call this property get function as below

System.Diagnostics.Debug.Print(index.DebugInfo);

In release mode this code does not compile. The error is
'Sesam.Studio.Stat.Database.Index' does not contain a definition for
'DebugInfo' .
It got confused of the error because I write this in a Debug call. Are
Debug calls excluded in Release mode or not? Why doesn't above code compile?
Jan 7 '06 #1
3 4010
Haldun,

Calls to the Debug class are not removed in release mode. Since you are
not exposing the type in release mode, you are essentially trying to access
a type that doesn't exist.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Haldun ALIML" <Haldun AL***@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Suppose that you have below property in some class,
#if DEBUG
public string DebugInfo
{
get
{
return "INDEX : " + _name + "\n" +
"Index Owner : " + _owner.Name + "\n" +
"Index Column Count: " + _columns.Count + "\n";
}
}
#endif

Somewhere you call this property get function as below

System.Diagnostics.Debug.Print(index.DebugInfo);

In release mode this code does not compile. The error is
'Sesam.Studio.Stat.Database.Index' does not contain a definition for
'DebugInfo' .
It got confused of the error because I write this in a Debug call. Are
Debug calls excluded in Release mode or not? Why doesn't above code
compile?

Jan 7 '06 #2
Thanks Nicholas for the answer.
In other words, is there any use or benefit of calls to Debug class in
release mode? I couldn't see any. In my opinion, these calls must be removed
from the code in release mode compilation. If they are removed, I won't have
to expose functions, properties that are only for debug purposes like my
DebugInfo. Is this clear?

"Nicholas Paldino [.NET/C# MVP]" wrote:
Haldun,

Calls to the Debug class are not removed in release mode. Since you are
not exposing the type in release mode, you are essentially trying to access
a type that doesn't exist.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Haldun ALIML" <Haldun AL***@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
Suppose that you have below property in some class,
#if DEBUG
public string DebugInfo
{
get
{
return "INDEX : " + _name + "\n" +
"Index Owner : " + _owner.Name + "\n" +
"Index Column Count: " + _columns.Count + "\n";
}
}
#endif

Somewhere you call this property get function as below

System.Diagnostics.Debug.Print(index.DebugInfo);

In release mode this code does not compile. The error is
'Sesam.Studio.Stat.Database.Index' does not contain a definition for
'DebugInfo' .
It got confused of the error because I write this in a Debug call. Are
Debug calls excluded in Release mode or not? Why doesn't above code
compile?


Jan 7 '06 #3
Halsdun,

It's not a matter of using the Debug class in release mode. It's still
going to do whatever you tell it to do, it's a class, like any other.

If you don't want the calls there, then you should wrap those sections
of code in a pre-processor directive (#if), or, for whole methods, you can
use the ConditionalAttribute.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Haldun ALIML" <Ha*********@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
Thanks Nicholas for the answer.
In other words, is there any use or benefit of calls to Debug class in
release mode? I couldn't see any. In my opinion, these calls must be
removed
from the code in release mode compilation. If they are removed, I won't
have
to expose functions, properties that are only for debug purposes like my
DebugInfo. Is this clear?

"Nicholas Paldino [.NET/C# MVP]" wrote:
Haldun,

Calls to the Debug class are not removed in release mode. Since you
are
not exposing the type in release mode, you are essentially trying to
access
a type that doesn't exist.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Haldun ALIML" <Haldun AL***@discussions.microsoft.com> wrote in message
news:A6**********************************@microsof t.com...
> Suppose that you have below property in some class,
> #if DEBUG
> public string DebugInfo
> {
> get
> {
> return "INDEX : " + _name + "\n" +
> "Index Owner : " + _owner.Name + "\n" +
> "Index Column Count: " + _columns.Count + "\n";
> }
> }
> #endif
>
> Somewhere you call this property get function as below
>
> System.Diagnostics.Debug.Print(index.DebugInfo);
>
> In release mode this code does not compile. The error is
> 'Sesam.Studio.Stat.Database.Index' does not contain a definition for
> 'DebugInfo' .
> It got confused of the error because I write this in a Debug call. Are
> Debug calls excluded in Release mode or not? Why doesn't above code
> compile?


Jan 7 '06 #4

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

Similar topics

6
by: Ariel | last post by:
I have an application that works correctly in debug mode but it does not work in release. I am not using anything of the class system.diagnostics. I tried to disable the optimization code, but...
4
by: Claire | last post by:
How do I determine whether Im running in debug or release mode from code please. thanks Claire
7
by: Srinivasa Rao | last post by:
I have read in one article that when we compile the application in release mode, all the debug classes and properties will be automatically removed from the code. I tried to implement this thing by...
4
by: Henry Padilla | last post by:
I found the following code snippet in the help but it doesn't seem to compile. Dim debugger As EnvDTE.Debugger Dim IsDebugging As Boolean debugger = DTE.Debugger If (debugger Is Nothing)...
2
by: Chris Pielak | last post by:
Hi. I'm about to try deploying my ASP.NET application, written with the 1.1 Framework. I'm coming across something odd when compiling in Debug and Release mode. When compiling in Debug mode, I...
5
by: Sagaert Johan | last post by:
Hi Can a lot of Console.Writeline commands cause a program to run slower ? johan
6
by: Rene | last post by:
Is there a way to tell if an assembly was compiled on Debug or Release mode? I tried viewing the file usin Ildasm but did't notice any special comment line or something that would tell me if it was...
6
by: Andrew Rowley | last post by:
I am having trouble getting debug and release builds to work properly with project references using C++ .NET and Visual Studio 2003. I created a test solution, with a basic Windows form C++...
4
by: Mel | last post by:
I want to send an email in release mode but not in debug mode, how would I accomplish this? Here is my email code (using vb.net, visual studio 2005, winxp pro sp2): Try Dim MailMsg As New...
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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,...

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.