This may sound a strange question, as I am very familiar with the normal difference between these two selections in say C++, but does it actually make any difference with .NET MF?
In project options, there are potentially ‘optimize code’ check boxes that one could select in a Release build, but as the whole thing is interpreted, is there any difference in choosing one over the other before doing a true release?
In theory it should also automatically strip out your debug statements when going to release. This ticket has already been submitted to Microsoft…
Also, one difference I have noticed in some projects is that they will not run in debug mode unless connected to the debugger. What I mean is that if I run a debug version and it gets deployed to the device and then I unplug USB and reboot the device, the code doesn’t seem to exist anymore. If I then swap to release and do the same thing then it works. Could be something weird I’m doing in my code. I haven’t spent much time researching it since I discovered the workaround.
For NETMF, Visual Studio doesn’t automatically non-compile the debug statements. You’ll find several threads about it here. They won’t cause the program to pause but they do effect program performance and size. The usual recommendation is to surround Debug functions as…
There is also an option to give a method the conditional attribute. The method itself and calls to this method will only compile into code if the conditional is true.
using System.Diagnostics; // used for conditional attribute
public class program
{
[Conditional("DEBUG")]
static void DebugPrint(string msg)
{
Debug.Print(msg);
}
public static void Main()
{
DebugPrint("This call and text will only exist in code/memory in DEBUG mode");
}
}