By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,610 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,610 IT Pros & Developers. It's quick & easy.

Debug Vs Release

P: n/a
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 using the following code in
Page_Load event handler.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim intcount As Integer
intcount = 0
For intcount = 0 To 4
Response.Write(intcount)
Debug.Assert(intcount = 3, "Yes it is 3.")
Next
End Sub

I have selected "Release" in the solution cofiguartions dropdown list and
compiled the application. The statement " Debug.Assert(intcount = 3, "Yes it
is 3.") " is not removed from the code. I have closed the solution and opened
the solution. Even then also the statement is not removed. What we have to do
if the statement has to be removed automatically?

Any help most welcome.

Regards
G.V.Srinivasa Rao.
Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Release mode does not remove statements, it simply does not provide a
programming debugging database file. (well it does some other stuff as
well). The major difference is that you will not be able to attach the
debugger in release mode because of the absence of that file. The compiler
does maintain the integrity and structure of your code, so the debug.assert
will still be there.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Srinivasa Rao" <Sr**********@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
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 using the following code in
Page_Load event handler.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim intcount As Integer
intcount = 0
For intcount = 0 To 4
Response.Write(intcount)
Debug.Assert(intcount = 3, "Yes it is 3.")
Next
End Sub

I have selected "Release" in the solution cofiguartions dropdown list and
compiled the application. The statement " Debug.Assert(intcount = 3, "Yes
it
is 3.") " is not removed from the code. I have closed the solution and
opened
the solution. Even then also the statement is not removed. What we have to
do
if the statement has to be removed automatically?

Any help most welcome.

Regards
G.V.Srinivasa Rao.

Nov 19 '05 #2

P: n/a
Srinivasa:
What are you using to see if the Debug.Assert is removed? It won't actually
remove it from the source code (which is what ou have bellow) but from the
actual assembly (the resulting DLL). If you get
http://www.aisto.com/roeder/dotnet/ it'll let you see this code and you
should see that, infact, Debug.Assert is removed when compiled in release
mode.

Also note that Debug.Assert doesn't work in aSP.Net.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Srinivasa Rao" <Sr**********@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
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 using the following code in
Page_Load event handler.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim intcount As Integer
intcount = 0
For intcount = 0 To 4
Response.Write(intcount)
Debug.Assert(intcount = 3, "Yes it is 3.")
Next
End Sub

I have selected "Release" in the solution cofiguartions dropdown list and
compiled the application. The statement " Debug.Assert(intcount = 3, "Yes
it
is 3.") " is not removed from the code. I have closed the solution and
opened
the solution. Even then also the statement is not removed. What we have to
do
if the statement has to be removed automatically?

Any help most welcome.

Regards
G.V.Srinivasa Rao.

Nov 19 '05 #3

P: n/a
Alvin:
I'm pretty sure this is incorrect. Release mode will renove all statements
from the System.Diagnostic.Debug class

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Release mode does not remove statements, it simply does not provide a
programming debugging database file. (well it does some other stuff as
well). The major difference is that you will not be able to attach the
debugger in release mode because of the absence of that file. The compiler
does maintain the integrity and structure of your code, so the debug.assert will still be there.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Srinivasa Rao" <Sr**********@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
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 using the following code in
Page_Load event handler.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim intcount As Integer
intcount = 0
For intcount = 0 To 4
Response.Write(intcount)
Debug.Assert(intcount = 3, "Yes it is 3.")
Next
End Sub

I have selected "Release" in the solution cofiguartions dropdown list and compiled the application. The statement " Debug.Assert(intcount = 3, "Yes it
is 3.") " is not removed from the code. I have closed the solution and
opened
the solution. Even then also the statement is not removed. What we have to do
if the statement has to be removed automatically?

Any help most welcome.

Regards
G.V.Srinivasa Rao.


Nov 19 '05 #4

P: n/a
Test it for yourself then. Build this in debug and compare the results to
release mode. On my system, the debug line is still in there.

[STAThread]

static void Main(string[] args)

{

System.Diagnostics.Debug.Assert(args != null);

}
You will find that the major difference between debug and release is that
optimization is turned on and debug symbols are not emitted. Most of this
optimization is done by the JITTER and not the language compiler so had you
prefaced your comment to specifiy the Jitted code you would have been
correct. Unfortunately, I was referring to the source code integrity, not
the IL code.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:et**************@tk2msftngp13.phx.gbl...
Alvin:
I'm pretty sure this is incorrect. Release mode will renove all
statements
from the System.Diagnostic.Debug class

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Release mode does not remove statements, it simply does not provide a
programming debugging database file. (well it does some other stuff as
well). The major difference is that you will not be able to attach the
debugger in release mode because of the absence of that file. The
compiler
does maintain the integrity and structure of your code, so the

debug.assert
will still be there.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Srinivasa Rao" <Sr**********@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
>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 using the following code
> in
> Page_Load event handler.
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim intcount As Integer
> intcount = 0
> For intcount = 0 To 4
> Response.Write(intcount)
> Debug.Assert(intcount = 3, "Yes it is 3.")
> Next
> End Sub
>
> I have selected "Release" in the solution cofiguartions dropdown list and > compiled the application. The statement " Debug.Assert(intcount = 3, "Yes > it
> is 3.") " is not removed from the code. I have closed the solution and
> opened
> the solution. Even then also the statement is not removed. What we have to > do
> if the statement has to be removed automatically?
>
> Any help most welcome.
>
> Regards
> G.V.Srinivasa Rao.



Nov 19 '05 #5

P: n/a
If I compile that code in debug mode then dissassemble the EXE, I get:
[STAThread]
private static void Main(string[] args)
{
Debug.Assert(args != null);
}

if I compile it in release mode than dissassemble the EXE, I get:

[STAThread]
private static void Main(string[] args)
{
}

or the IL for it:
DEBUG:
..method private hidebysig static void Main(string[] args) cil managed
{
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor()
.entrypoint
// Code Size: 13 byte(s)
.maxstack 2
L_0000: ldarg.0
L_0001: ldnull
L_0002: ceq
L_0004: ldc.i4.0
L_0005: ceq
L_0007: call void [System]System.Diagnostics.Debug::Assert(bool)
L_000c: ret
}


RELEASE:
..method private hidebysig static void Main(string[] args) cil managed
{
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor()
.entrypoint
// Code Size: 1 byte(s)
.maxstack 0
L_0000: ret
}
It should be noted that this is the default bahaviour in VS.Net...if you are
using the command line compiler, or another one, the behaviour might be
different.This is based on the DEBUG compilation flag. You can find out
more about this at:
http://msdn.microsoft.com/library/de...classtopic.asp

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Test it for yourself then. Build this in debug and compare the results to
release mode. On my system, the debug line is still in there.

[STAThread]

static void Main(string[] args)

{

System.Diagnostics.Debug.Assert(args != null);

}
You will find that the major difference between debug and release is that
optimization is turned on and debug symbols are not emitted. Most of this
optimization is done by the JITTER and not the language compiler so had you prefaced your comment to specifiy the Jitted code you would have been
correct. Unfortunately, I was referring to the source code integrity, not
the IL code.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:et**************@tk2msftngp13.phx.gbl...
Alvin:
I'm pretty sure this is incorrect. Release mode will renove all
statements
from the System.Diagnostic.Debug class

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Release mode does not remove statements, it simply does not provide a
programming debugging database file. (well it does some other stuff as
well). The major difference is that you will not be able to attach the
debugger in release mode because of the absence of that file. The
compiler
does maintain the integrity and structure of your code, so the

debug.assert
will still be there.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Srinivasa Rao" <Sr**********@discussions.microsoft.com> wrote in message news:CF**********************************@microsof t.com...
>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 using the following code
> in
> Page_Load event handler.
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim intcount As Integer
> intcount = 0
> For intcount = 0 To 4
> Response.Write(intcount)
> Debug.Assert(intcount = 3, "Yes it is 3.")
> Next
> End Sub
>
> I have selected "Release" in the solution cofiguartions dropdown list

and
> compiled the application. The statement " Debug.Assert(intcount = 3,

"Yes
> it
> is 3.") " is not removed from the code. I have closed the solution and > opened
> the solution. Even then also the statement is not removed. What we
have to
> do
> if the statement has to be removed automatically?
>
> Any help most welcome.
>
> Regards
> G.V.Srinivasa Rao.



Nov 19 '05 #6

P: n/a
I didn't say you were wrong. I said that I was referring to the source code
which is what the OP is referring to and not the IL code or the compiled
assembly.
I have selected "Release" in the solution cofiguartions dropdown list
and compiled the application. The statement " Debug.Assert(intcount = 3,
"Yes
it 3.") " is not removed from the code. Unfortunately, I was referring to the source code integrity, not
the IL code.
--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OT**************@TK2MSFTNGP09.phx.gbl... If I compile that code in debug mode then dissassemble the EXE, I get:
[STAThread]
private static void Main(string[] args)
{
Debug.Assert(args != null);
}

if I compile it in release mode than dissassemble the EXE, I get:

[STAThread]
private static void Main(string[] args)
{
}

or the IL for it:
DEBUG:
.method private hidebysig static void Main(string[] args) cil managed
{
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor()
.entrypoint
// Code Size: 13 byte(s)
.maxstack 2
L_0000: ldarg.0
L_0001: ldnull
L_0002: ceq
L_0004: ldc.i4.0
L_0005: ceq
L_0007: call void [System]System.Diagnostics.Debug::Assert(bool)
L_000c: ret
}


RELEASE:
.method private hidebysig static void Main(string[] args) cil managed
{
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor()
.entrypoint
// Code Size: 1 byte(s)
.maxstack 0
L_0000: ret
}
It should be noted that this is the default bahaviour in VS.Net...if you
are
using the command line compiler, or another one, the behaviour might be
different.This is based on the DEBUG compilation flag. You can find out
more about this at:
http://msdn.microsoft.com/library/de...classtopic.asp

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Test it for yourself then. Build this in debug and compare the results to
release mode. On my system, the debug line is still in there.

[STAThread]

static void Main(string[] args)

{

System.Diagnostics.Debug.Assert(args != null);

}
You will find that the major difference between debug and release is that
optimization is turned on and debug symbols are not emitted. Most of this
optimization is done by the JITTER and not the language compiler so had

you
prefaced your comment to specifiy the Jitted code you would have been
correct. Unfortunately, I was referring to the source code integrity, not
the IL code.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:et**************@tk2msftngp13.phx.gbl...
> Alvin:
> I'm pretty sure this is incorrect. Release mode will renove all
> statements
> from the System.Diagnostic.Debug class
>
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:%2******************@tk2msftngp13.phx.gbl...
>> Release mode does not remove statements, it simply does not provide a
>> programming debugging database file. (well it does some other stuff as
>> well). The major difference is that you will not be able to attach the
>> debugger in release mode because of the absence of that file. The
>> compiler
>> does maintain the integrity and structure of your code, so the
> debug.assert
>> will still be there.
>>
>> --
>> Regards,
>> Alvin Bruney [MVP ASP.NET]
>>
>> [Shameless Author plug]
>> The Microsoft Office Web Components Black Book with .NET
>> Now Available @ http://www.lulu.com/owc
>> ----------------------------------------------------------
>>
>>
>> "Srinivasa Rao" <Sr**********@discussions.microsoft.com> wrote in message >> news:CF**********************************@microsof t.com...
>> >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 using the following
>> > code
>> > in
>> > Page_Load event handler.
>> >
>> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles MyBase.Load
>> > Dim intcount As Integer
>> > intcount = 0
>> > For intcount = 0 To 4
>> > Response.Write(intcount)
>> > Debug.Assert(intcount = 3, "Yes it is 3.")
>> > Next
>> > End Sub
>> >
>> > I have selected "Release" in the solution cofiguartions dropdown
>> > list
> and
>> > compiled the application. The statement " Debug.Assert(intcount = 3,
> "Yes
>> > it
>> > is 3.") " is not removed from the code. I have closed the solution and >> > opened
>> > the solution. Even then also the statement is not removed. What we have > to
>> > do
>> > if the statement has to be removed automatically?
>> >
>> > Any help most welcome.
>> >
>> > Regards
>> > G.V.Srinivasa Rao.
>>
>>
>
>



Nov 19 '05 #7

P: n/a
Oh, my bad :) I sort of addressed this in my initial reply to the OP I
guess my head was within the context of my reply and not yours

karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:e$**************@TK2MSFTNGP10.phx.gbl...
I didn't say you were wrong. I said that I was referring to the source code which is what the OP is referring to and not the IL code or the compiled
assembly.
I have selected "Release" in the solution cofiguartions dropdown list
and compiled the application. The statement " Debug.Assert(intcount = 3,
"Yes
it 3.") " is not removed from the code.

Unfortunately, I was referring to the source code integrity, not
the IL code.


--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OT**************@TK2MSFTNGP09.phx.gbl...
If I compile that code in debug mode then dissassemble the EXE, I get:
[STAThread]
private static void Main(string[] args)
{
Debug.Assert(args != null);
}

if I compile it in release mode than dissassemble the EXE, I get:

[STAThread]
private static void Main(string[] args)
{
}

or the IL for it:
DEBUG:
.method private hidebysig static void Main(string[] args) cil managed
{
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor()
.entrypoint
// Code Size: 13 byte(s)
.maxstack 2
L_0000: ldarg.0
L_0001: ldnull
L_0002: ceq
L_0004: ldc.i4.0
L_0005: ceq
L_0007: call void [System]System.Diagnostics.Debug::Assert(bool)
L_000c: ret
}


RELEASE:
.method private hidebysig static void Main(string[] args) cil managed
{
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor()
.entrypoint
// Code Size: 1 byte(s)
.maxstack 0
L_0000: ret
}
It should be noted that this is the default bahaviour in VS.Net...if you
are
using the command line compiler, or another one, the behaviour might be
different.This is based on the DEBUG compilation flag. You can find out
more about this at:
http://msdn.microsoft.com/library/de...classtopic.asp
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Test it for yourself then. Build this in debug and compare the results to release mode. On my system, the debug line is still in there.

[STAThread]

static void Main(string[] args)

{

System.Diagnostics.Debug.Assert(args != null);

}
You will find that the major difference between debug and release is that optimization is turned on and debug symbols are not emitted. Most of this optimization is done by the JITTER and not the language compiler so had

you
prefaced your comment to specifiy the Jitted code you would have been
correct. Unfortunately, I was referring to the source code integrity, not the IL code.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:et**************@tk2msftngp13.phx.gbl...
> Alvin:
> I'm pretty sure this is incorrect. Release mode will renove all
> statements
> from the System.Diagnostic.Debug class
>
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:%2******************@tk2msftngp13.phx.gbl...
>> Release mode does not remove statements, it simply does not provide a >> programming debugging database file. (well it does some other stuff as >> well). The major difference is that you will not be able to attach the >> debugger in release mode because of the absence of that file. The
>> compiler
>> does maintain the integrity and structure of your code, so the
> debug.assert
>> will still be there.
>>
>> --
>> Regards,
>> Alvin Bruney [MVP ASP.NET]
>>
>> [Shameless Author plug]
>> The Microsoft Office Web Components Black Book with .NET
>> Now Available @ http://www.lulu.com/owc
>> ----------------------------------------------------------
>>
>>
>> "Srinivasa Rao" <Sr**********@discussions.microsoft.com> wrote in

message
>> news:CF**********************************@microsof t.com...
>> >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 using the following
>> > code
>> > in
>> > Page_Load event handler.
>> >
>> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles MyBase.Load
>> > Dim intcount As Integer
>> > intcount = 0
>> > For intcount = 0 To 4
>> > Response.Write(intcount)
>> > Debug.Assert(intcount = 3, "Yes it is 3.")
>> > Next
>> > End Sub
>> >
>> > I have selected "Release" in the solution cofiguartions dropdown
>> > list
> and
>> > compiled the application. The statement " Debug.Assert(intcount = 3, > "Yes
>> > it
>> > is 3.") " is not removed from the code. I have closed the solution

and
>> > opened
>> > the solution. Even then also the statement is not removed. What we

have
> to
>> > do
>> > if the statement has to be removed automatically?
>> >
>> > Any help most welcome.
>> >
>> > Regards
>> > G.V.Srinivasa Rao.
>>
>>
>
>



Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.