Operation may destabilize Enterprise Library 6

I created the .NET 4.5 Console application to try out the bits of the semantic log in the new Ent Lib v6. Using sample code from 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 may destabilize runtime." Looking at the stack trace in the helper of an exception 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() 

In 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, which 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 cause a problem that was found in other SO posts.

What did I miss? Has anyone really seen that the logging unit is working out of the box?

Thanks,

+4
source share
1 answer

The problem is in the main MS libraries.

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

This contains a fix for the problem. I burned several hours on it. Hopefully the next person who tries this should not waste as much time.

+5
source

Source: https://habr.com/ru/post/1499294/


All Articles