Skip to main content
 首页 » 编程设计

c#之NServiceBus升级后"Unable to find assembly"

2024年02月20日12lexus

对于即将发布的版本,我们已从 NServiceBus 3.0.3 升级到 3.2.7。我们在本地或 QA 测试期间没有遇到任何问题,但在暂存环境中测试时,我们无法启动引用 NServiceBus 的 IIS 托管的 Web 服务。

登台机使用与 QA 相同的软件; Windows 2008R2、IIS7.5

事件日志有两个错误。首先是事件 1026(.NET 运行时)

Application: w3wp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: NServiceBus.Unicast.Queuing.FailedToSendMessageException Stack: at NServiceBus.Unicast.Queuing.Msmq.MsmqMessageSender.NServiceBus.Unicast.Queuing.ISendMessages.Send(NServiceBus.Unicast.Transport.TransportMessage, NServiceBus.Address) at NServiceBus.Unicast.UnicastBus.SendSubscribeMessageWithRetries(NServiceBus.Address, NServiceBus.Unicast.Transport.TransportMessage, System.String, Int32) at NServiceBus.Unicast.UnicastBus+<>c_DisplayClass8.b_7(System.Object) at System.Threading.ExecutionContext.runTryCode(System.Object) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

后跟事件 1326 (ASP.NET 4.0.30319.0)

An unhandled exception occurred and the process was terminated.

Application ID: DefaultDomain

Process ID: 10180

Exception: System.Runtime.Serialization.SerializationException

Message: Unable to find assembly 'NServiceBus.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c'.

StackTrace: at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) at 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) at System.Runtime.Serialization.Formatters.Binary._BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) at System.Runtime.Serialization.Formatters.Binary._BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.AppDomain.Deserialize(Byte[] blob) at System.AppDomain.UnmarshalObject(Byte[] blob)

我检查了 bin 文件夹,它们确实包含正确版本的 NServiceBus.dll 和 NServiceBus.Core.dll(并且都是相同的版本,3.2.7)。

我感觉很困惑,我想我已经检查了一些显而易见的事情。可能是它试图加载多个版本的 NServiceBus(即一些未更新的引用?)。但是,这应该是 QA 中的一个问题?

请您参考如下方法:

虽然是个老问题,但我遇到了这个问题,而且我有一个解决方法。

第一个enable fusion logging .确保进程可以写入日志文件夹。

接下来,检查进程正在寻找的位置。在我的例子中,它只是搜索 file:///c:/windows/system32/inetsrv/ 所以我在那里添加了 dll NServiceBus.Core.DLL,现在我可以看到真正的问题。

我的猜测是在后台线程上发生了未处理的异常(第一个错误),然后将其序列化并传递给主线程,主线程试图对其进行反序列化,但找不到程序集(第二个错误)。第二个错误杀死了应用程序池,意味着我丢失了真正的错误。

此解决方法仅解决第二个错误,而不是原始问题。话虽如此,到目前为止,这足以让我让应用程序再次运行并找到真正的错误,对我来说是 MSMQ 内存不足。所以我重新启动了 MSMQ,它已经开始工作了。然后,我从新位置删除了 NServiceBus.Core.DLL,该应用程序仍在运行。

记录输出:

The operation failed. 
Bind result: hr = 0x80070002. The system cannot find the file specified. 
 
Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll 
 
=== Pre-bind state information === 
LOG: User = IIS APPPOOL\TenBagsFull 
LOG: DisplayName = NServiceBus.Core 
 (Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: NServiceBus.Core | Domain ID: 1 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///c:/windows/system32/inetsrv/ 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = w3wp.exe 
Calling assembly : (Unknown). 
=== 
LOG: This bind starts in default load context. 
LOG: No application configuration file found. 
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/NServiceBus.Core.DLL. 
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/NServiceBus.Core/NServiceBus.Core.DLL. 
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/NServiceBus.Core.EXE. 
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/NServiceBus.Core/NServiceBus.Core.EXE. 
LOG: All probing URLs attempted and failed. 
Running under executable  c:\windows\system32\inetsrv\w3wp.exe 
--- A detailed error log follows.