locked
Debug.Writeline magicly stops working... why???? RRS feed

  • Question

  • Hi all,

    I have searched and searched for this and found many answers - none of which have fixed my problem.

    Here is the key code in my static debug class:

    private static readonly Mutex DebugMutex = new Mutex(false, @"Global\DebugMutex");
    public static void writeIt(String debugMsg)
    {
    	DebugMutex.WaitOne();
    	Debug.WriteLine(debugMsg);
    	DebugMutex.ReleaseMutex();
    }

    Nothing fancy.  When my VS 2012 C# 4.0 FW WPF application starts, I see the messages appear in the output window as expected.

    Then, for no apparent reason, the WriteLine will no longer output to the output window. 

    I have tried the following:

    • Added Mutex to handle multi threading issues (in code sample above)
    • Deleted all the code in the bin and obj folder contents, done a clean all, and rebuild all (and yes, I completely exited VS 2012 before I deleted the folder contents.
    • Have made sure that ALL the projects in the solution have a build platform target of x86
    • Made sure that ALL have the DEBUG and TRACE constant checkboxes checked
    • Made sure that ALL target .NET FW 4 (or 4 Client Profile)
    • Repeatedly exited and restarted VS 2012 (remember that it does work in the beginning, just suddenly stops at some point.)
    • Note - the above is an excerpt as there is a bunch of other code that decides if I should use a trace instead of debug, etc.  But I step through the code on this line and when I step over the WriteLine statement - NOTHING appears in the output window.  (and yes, I did check the immediate window although I did not set it to output there.)
    • I have unchecked "Enable Just My Code"
    • I have all the General Output Settings set to ON (I have not changed the WPF settings, but the problem appears before I try to display my first WPF form.)
    • Have stepped through the code to insure that the line with Debug.Writeline() does get executed.
    • Have searched MSDN (although the default search doesn't seem to work very well), Google, and Bing and tried all the things I could find in those searches to no avail.

    I am using some 3rd party libraries, so there is a chance that they may be executing some code that turns off debugging (although I can't imagine why), but I am not aware of those commands so can't check (or just write some code to set whatever back to normal.)

    Any idea why this may be happening or what options I have to make it so that the Debug.Output always shows?

    Your help is GREATLY appreciated as I have a bunch of code to debug and this is REALLY frustrating.

    Thanks!


    me (and yes, I DO mark correct answers)

    Thursday, June 6, 2013 10:32 PM

All replies

  • Ok, one more interesting piece of information.  In desperation (and until I got an answer from this msg that solved the problem) I decided to use console.WriteLine().  Guess what - it consistently sends everything to the output window the way debug.writeline() should.  Go figure...

    I still want to solve this as using console.writeline() has some potential side effects in released code.  But it's interesting that using console seems to work.

    Again, any help to fix this is greatly appreciated.


    me (and yes, I DO mark correct answers)

    Thursday, June 6, 2013 10:42 PM