Claire,
While most of these suggestions are acceptable, I think that you should
use reflection to determine whether or not the assembly has the Debuggable
attribute attached to it. Most compilers (should) attach this to any
assembly compiled in debug mode. The C# compiler definitely does, and I
think it would be safe to say that the other .NET compilers issued by MS do
as well.
In order to determine whether or not the assembly was compiled in debug
mode, get the Debuggable attribute from the assembly.
Assuming that you have an Assembly instance, this is how you would do
it:
// The assembly is in a variable named assembly.
object[] attributes =
assembly.GetCus tomAttributes(t ypeof(Debuggabl eAttribute), true);
// If the array is null, or has length of zero, then it is not debuggable.
if (!(attributes == null || attributes.leng th == 0))
{
// It is debuggable, figure out the level.
DebuggableAttri bute debug = (DebuggableAttr ibute) attributes[0];
// At this point, you can access the DebuggingFlags property to
determine the level of debugging.
}
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard. caspershouse.co m
"Claire" <bl****@blahhhh h.com> wrote in message
news:OD******** *****@tk2msftng p13.phx.gbl...
How do I determine whether Im running in debug or release mode from code
please.
thanks
Claire