2013-08-28 24 views
4

我創建了一個.NET 4.5控制檯應用程序來嘗試新的Ent Lib v6中的語義記錄位。使用 從PDF的代碼示例:操作可能會導致運行時不穩定企業庫6

var listener2 = new ObservableEventListener(); 
listener2.EnableEvents(EventSourceCore.Log , EventLevel.LogAlways , Keywords.All); 
SinkSubscription<SqlDatabaseSink> subscription = listener2.LogToSqlDatabase("Demo Semantic Logging Instance" , ConfigurationManager.AppSettings["mdbconn"]); 

運行代碼立即給出了錯誤「操作可能會破壞運行時」。看從VS2012異常助手內的堆棧跟蹤,我看到

at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy`1..ctor(Int32 retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff) 
    at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink..ctor(String instanceName, String connectionString, String tableName, TimeSpan bufferingInterval, Int32 bufferingCount, Int32 maxBufferSize, TimeSpan onCompletedTimeout) 
    at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.SqlDatabaseLog.LogToSqlDatabase(IObservable`1 eventStream, String instanceName, String connectionString, String tableName, Nullable`1 bufferingInterval, Int32 bufferingCount, Nullable`1 onCompletedTimeout, Int32 maxBufferSize) 
    at svc2.Program.LogPrep() in c:\cos\Program.cs:line 66 
    at svc2.Program.Main(String[] args) in c:\cos\Program.cs:line 23 
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
    at System.Threading.ThreadHelper.ThreadStart() 

綜觀Entlib源代碼,在SqlDatabaseSink.cs線32示出了

private readonly RetryPolicy retryPolicy = new RetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>(5, TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(5)); 

打算在RetryPolicyGeneric.cs到線路59那顯示

public RetryPolicy(int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff) 
      : base(new T(), retryCount, minBackoff, maxBackoff, deltaBackoff) 

但我沒有看到任何隱含的轉換,可能會導致問題,在其他SO帖子中找到。

我錯過了什麼?有沒有人真的看到日誌塊「開箱即用」?

謝謝,

回答

相關問題