为什么 SLAB Sql Database Sync 停止写入 Traces table?
Why SLAB SqlDatabaseSink stopped writing to Traces table?
SLAB SqlDatabaseSink 停止写入 Traces table
我并行添加了一个 FlatFileSink 以确保侦听器不是问题所在,它可以很好地写入文件。
我还有一个 SqlDatabaseSink 的单元测试,它工作正常,但是当通过 Global.asax 从主项目订阅时,只有 FlatFileSink 工作。截图如下。
根据@manikrish 的建议添加了 SLAB 内部事件侦听器(非常感谢),这是来自该日志的底层 SQLDatabaseSink 错误"Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'" - 下面的详细信息,SLAB 内部日志。
接下来,我比较了主项目和单元测试项目(谁的 SQLDatabaseSink 工作) 之间 Newtonsoft.Json 的参考属性,两者都使用版本 6.0.8(我相信WebApi 5.2.3 随附),但 注意到后者 中的特定版本为 False。所以,我在主项目中做了同样的更改,仍然没有运气。
此外,主项目的 web.config 和单元测试项目的 app.config 也具有相同的程序集绑定:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
接下来,我尝试通过更改 web.config、packages.config、csproj 中的引用属性来解决绑定重定向问题; reinstalling/updating Newtonsoft.Json 以及调用程序集的 (Microsoft.Practices.EnterpriseLibrary.SemanticLogging) NuGet 包 基于其他 Whosebug 问题(下面的链接),仍然没有运气 - SLAB 内部日志中存在相同的绑定错误,没有我的投标重定向的证据。
SLAB 内部日志:
Opcode : Info
Task : 65433
Version : 0
Payload : [message : System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
at System.Data.SqlClient.SqlParameter.GetCoercedValue()
at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryInternal(AsyncCallback callback, Object stateObject, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryAsync(AsyncCallback callback, Object stateObject)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl(Func`3 beginMethod, Func`2 endFunction, Action`1 endAction, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory`1.FromAsync(Func`3 beginMethod, Func`2 endMethod, Object state)
at System.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<>c__DisplayClass14.<<UseStoredProcedure>b__13>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<UseStoredProcedure>d__1d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<PublishEventsAsync>d__0.MoveNext()
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///C:/work/StarLims/AMO/server/TFS/AMO/eyeNet/AI.eyeNet/
LOG: Initial PrivatePath = C:\work\StarLims\AMO\server\TFS\AMO\eyeNet\AI.eyeNet\bin
Calling assembly : Microsoft.Practices.EnterpriseLibrary.SemanticLogging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\work\StarLims\AMO\server\TFS\AMO\eyeNet\AI.eyeNet\web.config
LOG: Using host configuration file: C:\Users\siliodx\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74a40fb9/3b0c98c/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74a40fb9/3b0c98c/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/work/StarLims/AMO/server/TFS/AMO/eyeNet/AI.eyeNet/bin/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
]
EventName : DatabaseSinkPublishEventsFailedInfo
Timestamp : 2015-06-05T11:56:54.5518724Z
ProcessId : 6752
ThreadId : 12060
Whosebug 支持链接:
Infamous assembly binding error
Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference
Newtonsoft.Json.dll issue when using multiple projects
Assembly mismatch despite having assembly redirect and loading correct version
截图:
语义日志记录应用程序块将内部事件记录到称为 SemanticLoggingEventSource 的预定义事件源。您可以创建一个额外的侦听器,将来自此事件源的事件记录到不同的接收器。
例如,下面的代码片段显示了如何将内部事件记录到文件中:
var slabInternalNotificationsListener = new ObservableEventListener();
slabInternalNotificationsListener.LogToFlatFile(@".\errors.txt");
slabInternalNotificationsListener.EnableEvents(SemanticLoggingEventSource.Log, System.Diagnostics.Tracing.EventLevel.Verbose, Keywords.All);
请查看来自 SemanticLoggingEventSource 的日志,了解 SQL 接收器未记录事件的原因。
根本原因 是 web.config 中的一个程序集周围缺少 dependentAssembly 标记:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
非常感谢 Mani and the other SLAB team members 对我的帮助,特别是因为根本原因与他们的项目无关。
SLAB SqlDatabaseSink 停止写入 Traces table
我并行添加了一个 FlatFileSink 以确保侦听器不是问题所在,它可以很好地写入文件。 我还有一个 SqlDatabaseSink 的单元测试,它工作正常,但是当通过 Global.asax 从主项目订阅时,只有 FlatFileSink 工作。截图如下。
根据@manikrish 的建议添加了 SLAB 内部事件侦听器(非常感谢),这是来自该日志的底层 SQLDatabaseSink 错误"Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'" - 下面的详细信息,SLAB 内部日志。
接下来,我比较了主项目和单元测试项目(谁的 SQLDatabaseSink 工作) 之间 Newtonsoft.Json 的参考属性,两者都使用版本 6.0.8(我相信WebApi 5.2.3 随附),但 注意到后者 中的特定版本为 False。所以,我在主项目中做了同样的更改,仍然没有运气。
此外,主项目的 web.config 和单元测试项目的 app.config 也具有相同的程序集绑定:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
接下来,我尝试通过更改 web.config、packages.config、csproj 中的引用属性来解决绑定重定向问题; reinstalling/updating Newtonsoft.Json 以及调用程序集的 (Microsoft.Practices.EnterpriseLibrary.SemanticLogging) NuGet 包 基于其他 Whosebug 问题(下面的链接),仍然没有运气 - SLAB 内部日志中存在相同的绑定错误,没有我的投标重定向的证据。
SLAB 内部日志:
Opcode : Info
Task : 65433
Version : 0
Payload : [message : System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
at System.Data.SqlClient.SqlParameter.GetCoercedValue()
at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryInternal(AsyncCallback callback, Object stateObject, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryAsync(AsyncCallback callback, Object stateObject)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl(Func`3 beginMethod, Func`2 endFunction, Action`1 endAction, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory`1.FromAsync(Func`3 beginMethod, Func`2 endMethod, Object state)
at System.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<>c__DisplayClass14.<<UseStoredProcedure>b__13>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<UseStoredProcedure>d__1d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<PublishEventsAsync>d__0.MoveNext()
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///C:/work/StarLims/AMO/server/TFS/AMO/eyeNet/AI.eyeNet/
LOG: Initial PrivatePath = C:\work\StarLims\AMO\server\TFS\AMO\eyeNet\AI.eyeNet\bin
Calling assembly : Microsoft.Practices.EnterpriseLibrary.SemanticLogging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\work\StarLims\AMO\server\TFS\AMO\eyeNet\AI.eyeNet\web.config
LOG: Using host configuration file: C:\Users\siliodx\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74a40fb9/3b0c98c/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74a40fb9/3b0c98c/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/work/StarLims/AMO/server/TFS/AMO/eyeNet/AI.eyeNet/bin/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
]
EventName : DatabaseSinkPublishEventsFailedInfo
Timestamp : 2015-06-05T11:56:54.5518724Z
ProcessId : 6752
ThreadId : 12060
Whosebug 支持链接:
Infamous assembly binding error
Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference
Newtonsoft.Json.dll issue when using multiple projects
Assembly mismatch despite having assembly redirect and loading correct version
截图:
语义日志记录应用程序块将内部事件记录到称为 SemanticLoggingEventSource 的预定义事件源。您可以创建一个额外的侦听器,将来自此事件源的事件记录到不同的接收器。
例如,下面的代码片段显示了如何将内部事件记录到文件中:
var slabInternalNotificationsListener = new ObservableEventListener();
slabInternalNotificationsListener.LogToFlatFile(@".\errors.txt");
slabInternalNotificationsListener.EnableEvents(SemanticLoggingEventSource.Log, System.Diagnostics.Tracing.EventLevel.Verbose, Keywords.All);
请查看来自 SemanticLoggingEventSource 的日志,了解 SQL 接收器未记录事件的原因。
根本原因 是 web.config 中的一个程序集周围缺少 dependentAssembly 标记:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
非常感谢 Mani and the other SLAB team members 对我的帮助,特别是因为根本原因与他们的项目无关。