操作可能会破坏运行时企业库6的稳定性

Sno*_*owy 4 .net logging enterprise-library verificationexception

我创建了一个.NET 4.5控制台应用程序来尝试新的Ent Lib v6中的语义记录位.使用PDF中的示例代码:

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

立即运行代码会出现错误"操作可能使运行时不稳定".我看到VS2012中Exception帮助器中的堆栈跟踪

  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()
Run Code Online (Sandbox Code Playgroud)

查看Entlib源代码,SqlDatabaseSink.cs中的第32行显示

 private readonly RetryPolicy retryPolicy = new RetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>(5, TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(5));
Run Code Online (Sandbox Code Playgroud)

转到显示的RetryPolicyGeneric.cs中的第59行

 public RetryPolicy(int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff)
            : base(new T(), retryCount, minBackoff, maxBackoff, deltaBackoff)
Run Code Online (Sandbox Code Playgroud)

但我没有看到任何可能导致问题的隐式演员,这在其他SO帖子中找到.

我错过了什么?有没有人真正看到日志块工作"开箱即用"?

谢谢,

Sno*_*owy 5

问题出在核心MS库中.

http://support.microsoft.com/kb/2748645

这包含问题的补丁.我在那个上烧了好几个小时.希望下一个尝试这一点的人不必失去相同的时间.