平板SqlDatabaseSink停止了对跟踪表的写入
我并行地添加了一个FlatFileSink,以确保监听器不是问题,它可以很好地写入文件。我还为SqlDatabaseSink提供了一个单元测试,它工作得很好,但是当通过Global.asax订阅主项目时,只有FlatFileSink工作。下面是截图。
添加了板坯内部事件侦听器 per @manikrish的建议(非常感谢您的建议),下面是来自该日志的基本SQLDatabaseSink错误“无法加载文件或程序集'Newtonsoft.Json,Version=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed'”--下面的详细信息,平板内部日志。
接下来,我比较了主项目和单元测试项目(who's SQLDatabaseSink works)之间的引用属性,它们都使用6.0.8版本(我相信WebApi 5.2.3附带了),但注意到在后者中特定版本是假的。所以,我在主项目中做了同样的修改,但仍然没有成功。
此外,主项目的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>
接下来,我尝试通过更改(Microsoft.Practices.EnterpriseLibrary.SemanticLogging)、packages.config、csproj中的引用属性来解决绑定重定向问题;基于其他堆栈溢出问题(下面的链接)重新安装/更新Newtonsoft.Json以及调用程序集的Newtonsoft.Json NuGet包,但仍然没有运气--板坯内部日志中相同的绑定错误,没有迹象表明我正在重定向。
平板内部原木:
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
StackOverflow支持链接:
无法加载文件或程序集“Newtonsoft.Json”或其依赖项之一。清单定义与程序集引用不匹配。
截图:
发布于 2015-06-19 03:37:10
根原因是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>
发布于 2015-06-04 11:33:24
语义日志应用程序块将内部事件记录到一个名为SemanticLoggingEventSource的预定义事件源。您可以创建一个额外的侦听器,它将事件从此事件源记录到不同的接收器。
例如,下面的代码片段显示了如何将内部事件记录到文件中:
var slabInternalNotificationsListener = new ObservableEventListener();
slabInternalNotificationsListener.LogToFlatFile(@".\errors.txt");
slabInternalNotificationsListener.EnableEvents(SemanticLoggingEventSource.Log, System.Diagnostics.Tracing.EventLevel.Verbose, Keywords.All);
请查看来自SemanticLoggingEventSource的日志,以了解SQL接收器没有记录事件的原因。
https://stackoverflow.com/questions/30644279
复制相似问题