471,337 Members | 1,115 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 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 3874
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Srinivasa Rao | last post: by
2 posts views Thread by Chris Pielak | last post: by
6 posts views Thread by Rene | last post: by
6 posts views Thread by Andrew Rowley | last post: by
4 posts views Thread by Mel | last post: by
reply views Thread by rosydwin | last post: by

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.