Debug Vs Release

G

Guest

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.
 
A

Alvin Bruney [MVP]

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
 
K

Karl Seguin

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
 
K

Karl Seguin

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 said:
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 said:
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.
 
A

Alvin Bruney [MVP]

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 said:
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 said:
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 said:
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.
 
K

Karl Seguin

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/d...tml/frlrfsystemdiagnosticsdebugclasstopic.asp

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Alvin Bruney said:
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 said:
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 said:
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
----------------------------------------------------------


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.
 
A

Alvin Bruney [MVP]

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 said:
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/d...tml/frlrfsystemdiagnosticsdebugclasstopic.asp

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Alvin Bruney said:
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 said:
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
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
----------------------------------------------------------


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.
 
K

Karl Seguin

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 said:
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 said:
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/d...tml/frlrfsystemdiagnosticsdebugclasstopic.asp

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Alvin Bruney said:
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 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
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
----------------------------------------------------------


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top