My logging library has a simple DebugLogger that looks like this:
public class DebugLogger : Logger
{
protected override void PerformLogging(string entry)
{
Debug.WriteLine(entry);
}
}
The logging library has been built in RELEASE mode.
An application that references the logging library is being developed in DEBUG mode, naturally.
The problem is that when the application using the logging library calls DebugLogger.PerformLogging("some debug message") nothing shows up in the Visual Studio debug output.
I have verified things do work as expected when the logging assembly is built in DEBUG mode.
I was expecting that that the entry assembly being in DEBUG mode would take precedence, but it looks like this is not the case.
Is there anything that can be done?
edit
http://msdn.microsoft.com/en-us/library/6x31ezs1.aspx in the remarks section talks about the compiler ignoring Debug methods without DEBUG being defined.
How the
Debug.WriteLinecall is processed is determined when the project containing the call is compiled. In this case the C# compiler sees a call toDebug.WriteLinein a Release project (DEBUGnot defined) and hence doesn’t emit the call into the resulting IL. At this point thePerformLoggingmethod has no reference toDebug.WriteLineand hence no call from a build of any type will execute aDebug.WriteLinecall.