Operation could destabilize the runtime Enterprise Library 6
I created a .NET 4.5 Console app to try out the Semantic Logging bits in
the new Ent Lib v6. Using the sample code from the 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"] );
Running the code immediately gives the error "Operation could destabilize
the runtime". Looking at the stack trace within the Exception helper from
VS2012, I see
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()
Looking at the Entlib source code, line 32 in SqlDatabaseSink.cs shows
private readonly RetryPolicy retryPolicy = new
RetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>(5,
TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(1),
TimeSpan.FromSeconds(5));
Going to line 59 in RetryPolicyGeneric.cs that shows
public RetryPolicy(int retryCount, TimeSpan minBackoff, TimeSpan
maxBackoff, TimeSpan deltaBackoff)
: base(new T(), retryCount, minBackoff, maxBackoff, deltaBackoff)
But I don't see anything like an implicit cast that could be causing the
problem, that was found in other SO posts.
What did I miss? Has anyone actually seen the logging block work "out of
the box"?
Thanks,
No comments:
Post a Comment