I have a WCF console application that includes the SlimDX library. SlimDX outputs a log using the 'Write' method of System.Diagnostics.Debug. I am currently not able to view this log in the console. I would like to capture the output from SlimDX and write it to the console.
Here is my implementation so far (not working):
FileStream fs = new FileStream("C:/users/paulm/documents/output.txt", FileMode.Create);
Writer = new StreamWriter(fs);
System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(Writer));
This implementation is not capturing the output from SlimDX. Here is SlimDX source code:
#include "ObjectTable.h"
#include "InternalHelpers.h"
#include "ComObject.h"
using namespace System;
using namespace System::Text;
using namespace System::Threading;
using namespace System::Globalization;
using namespace System::Collections::ObjectModel;
using namespace System::Collections::Generic;
using namespace System::Diagnostics;
namespace SlimDX
{
static ObjectTable::ObjectTable()
{
m_Table = gcnew Dictionary<IntPtr, ComObject^>();
m_Ancillary = gcnew Dictionary<IntPtr, List<ComObject^>^>();
m_SyncObject = gcnew Object();
AppDomain::CurrentDomain->DomainUnload += gcnew System::EventHandler( OnExit );
AppDomain::CurrentDomain->ProcessExit += gcnew System::EventHandler( OnExit );
}
ObjectTable::ObjectTable()
{
}
void ObjectTable::OnExit( Object^ sender, EventArgs^ e )
{
SLIMDX_UNREFERENCED_PARAMETER(sender);
SLIMDX_UNREFERENCED_PARAMETER(e);
String^ leakString = ReportLeaks();
Debug::Write( leakString ); // this is the output I would like to capture
}
Any insights as to what I would need to modify wrt WCF in order to capture SlimDX output?
Debug class has a Default Trace Listener if none is specified. So you should be able to see the log in the Output Window of Visual Studio. (Debug->Windows->Output) However, if you are in Release mode then it will not log to the output window. Try executing the program in Debug mode or add "#define DEBUG" on top of your file and then execute. Hope it helps!