Question: I have a referenced library, inside there I want to perform a different action if the assembly that references it is in DEBUG/RELEASE mode. 

Is it possible to switch on the condition that the calling assembly is in DEBUG/RELEASE mode?

Is there a way to do this without resorting to something like:

```
bool debug = false;

#if DEBUG
debug = true;
#endif

referencedlib.someclass.debug = debug;

```

The referencing assembly will always be the starting point of the application (i.e. web application.

Answer: 
[Google says](http://stevesmithblog.com/blog/determine-whether-an-assembly-was-compiled-in-debug-mode/) it is very simple. You get the information from the [DebuggableAttribute](http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggableattribute.aspx) of the assembly in question:

```
IsAssemblyDebugBuild(Assembly.GetCallingAssembly());

private bool IsAssemblyDebugBuild(Assembly assembly)
{
    foreach (var attribute in assembly.GetCustomAttributes(false))
    {
        var debuggableAttribute = attribute as DebuggableAttribute;
        if(debuggableAttribute != null)
        {
            return debuggableAttribute.IsJITTrackingEnabled;
        }
    }
    return false;
}

```
You can use [reflection](http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getcallingassembly.aspx) to get the calling assembly and use [this method](http://stevesmithblog.com/blog/determine-whether-an-assembly-was-compiled-in-debug-mode/) to check if it is in debug mode.