【问题标题】:Unable to find assembly System.Diagnostics.DiagnosticSource when using Remoting使用远程处理时找不到程序集 System.Diagnostics.DiagnosticSource
【发布时间】:2017-09-13 18:57:14
【问题描述】:

将 Application Insights 添加到我的 ASP.NET 应用程序(使用 .NET 4.5.2 的标准 ASP.NET)后,我发现使用 .NET 远程处理时出现异常。例外是:

找不到程序集 'System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

我不太明白这里发生了什么(似乎跟踪正在跨越应用程序域边界),但如果我将 System.Diagnostics.DiagnosticSource NuGet 包添加到远程服务,错误就会消失。

不幸的是,我刚刚发现在尝试使用 SqlDependency 触发缓存刷新时也遇到了这个错误。有没有办法在使用远程处理时禁用此跟踪,如果这是实际发生的情况,还是有其他方法可以解决此问题?

服务器堆栈跟踪:
   在 System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
   在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo 组件信息,字符串名称)
   在 System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable )
   在 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped 记录)
   在 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
   在 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler 处理程序,__BinaryParser serParser,布尔 fCheck,布尔 isCrossAppDomain,IMethodCallMessage methodCallMessage)
   在 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(流序列化流,HeaderHandler 处理程序,布尔 fCheck,布尔 isCrossAppDomain,IMethodCallMessage methodCallMessage)
   在 System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
   在 System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.FixupForNewAppDomain()
   在 System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(字节 [] reqStmBuff,SmuggledMethodCallMessage smuggledMcm,SmuggledMethodReturnMessage& smuggledMrm)
   在 System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)

在 [0] 处重新抛出异常:
   在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
   在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 类型)
   在 System._AppDomain.CreateInstance(字符串组件名称,字符串类型名称)
   在 System.Data.SqlClient.SqlDependency.CreateProcessDispatcher(_AppDomain masterDomain)
   在 System.Data.SqlClient.SqlDependency.ObtainProcessDispatcher()
   在 System.Data.SqlClient.SqlDependency.Start(String connectionString, String queue, Boolean useDefaults)

【问题讨论】:

  • 这里有同样的问题。似乎 Application Insights 将此程序集的某些内容附加到了消息中。

标签: remoting azure-application-insights .net-remoting


【解决方案1】:

我通过升级到 System.Diagnostics.DiagnosticSource 4.5.0 修复了它

问题在于 Application Insights 创建了 System.Diagnostics.Activity 的实例并将其存储在 CallContext (LogicalCallContext) 中。在远程调用期间,CallContext 被编组到远程服务器。不幸的是,这个 .dll 不存在。

在我的情况下,更糟糕的是,远程服务器是在 .NET 2.0 上运行的旧版应用程序,在那里复制 dll 并没有解决问题。

你可以在https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/613找到更多信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    • 1970-01-01
    • 1970-01-01
    • 2015-04-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多