Reading the System.Diagnostics.Debug window
<p>I have a <a href="http://netduino.com/" rel="nofollow">Netduino</a> and it is currently outputting accelerometer data to the System. Diagnostics.Debug window. I am waiting on a USB->232 converter in the mail to properly get the data from the device into my app via a serial port but I was wondering just for quick testing purposes if anyone knows if it is possible to read the data from the Debug window back into my app?</p>

<p><strong>EDIT - Solution:</strong>
I am posting this here for anyone who want my solution. I originally thought that Nuf's answer worked "Data written to System.Diagnostics.Debug can be captured with TraceListener class. MSDN has short tutorial how to set it up." but I found out that the Listener can only get data from within it's own application. Since I was using a Netduino, the Debug output was from a different program which meant the trace listener could not read it. So I found a way to read the text in the Output box directly.</p>

<p>Base on code from MSDN:
You will need to 3 references to your project. They are located in the .Net reference tab - EnvDTE, EnvDTE80, and extensibility.</p>

<pre><code>using EnvDTE80;
using EnvDTE;
using Extensibility;

        public static string ReadDebugBox()
        {
            EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0");
            string data = "";
            OutputWindow ow = dte.ToolWindows.OutputWindow;
            OutputWindowPane owP;

            TextDocument owPTxtDoc;
            EditPoint2 strtPt;

            owP = ow.OutputWindowPanes.Item("Debug");
            owP.Activate();
            owPTxtDoc = owP.TextDocument;

            strtPt = (EditPoint2)owPTxtDoc.StartPoint.CreateEditPoint();
            return strtPt.GetText(owPTxtDoc.EndPoint);
        }



            public static void ClearDebugBox()
            {
                EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0");
                OutputWindow ow = dte.ToolWindows.OutputWindow;
                OutputWindowPane owP;

                TextDocument owPTxtDoc;
                EditPoint2 strtPt;

                owP = ow.OutputWindowPanes.Item("Debug");
                owP.Activate();

                owP.Clear();
            }
</code></pre>

<p>There may be better ways of doing it but this is just one that worked for me so i thought I would share it.</p>
