【问题标题】:Operation could destabilize the runtime Enterprise Library 6操作可能会破坏运行时企业库 6
【发布时间】:2013-08-28 04:11:10
【问题描述】:

我创建了一个 .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"] );

立即运行代码会出现错误“操作可能会破坏运行时”。查看 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 帖子中发现。

我错过了什么?有没有人真正看到过“开箱即用”的日志记录块?

谢谢,

【问题讨论】:

    标签: .net logging enterprise-library verificationexception


    【解决方案1】:

    问题出在核心 MS 库中。

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

    其中包含解决问题的补丁。我在那上面烧了几个小时。希望下一个尝试这个的人不会浪费同样多的时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      • 2012-11-05
      • 1970-01-01
      • 1970-01-01
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多