【发布时间】:2017-12-30 02:23:40
【问题描述】:
我有一个包含 SlimDX 库的 WCF 控制台应用程序。 SlimDX 使用 System.Diagnostics.Debug 的 'Write' 方法输出日志。我目前无法在控制台中查看此日志。我想捕获 SlimDX 的输出并将其写入控制台。
这是我目前的实现(不工作):
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));
此实现未捕获 SlimDX 的输出。这里是 SlimDX 源代码:
#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
}
关于我需要修改 wrt WCF 以捕获 SlimDX 输出的任何见解?
【问题讨论】: