我正在将aspure服务总线功能实现到客户端asp.net webforms解决方案中。
工作者角色定期轮询总线以获取新消息,并为现有的webforms应用程序定义Web角色,该角色负责在总线队列中添加消息。
每当我尝试在本地运行应用程序时,由于Microsoft.ServiceBus程序集与预期不匹配而导致错误...
System.IO.FileLoadException was unhandled
HResult=-2146234304
Message=Could not load file or assembly 'Microsoft.ServiceBus, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Azure.EnquiryWorker
FileName=Microsoft.ServiceBus, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog==== Pre-bind state information ===
LOG: User = *Omitted*
LOG: DisplayName = Microsoft.ServiceBus, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/*path omitted*/*project name omitted*/csx/Debug/roles/Azure.EnquiryWorker/approot
LOG: Initial PrivatePath = C:\Users\*path omitted*/*project name omitted*\csx\Debug\roles\Azure.EnquiryWorker\approot
Calling assembly : Azure.EnquiryWorker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\*path omitted*/*project name omitted*\csx\Debug\roles\Azure.EnquiryWorker\approot\Azure.EnquiryWorker.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.ServiceBus, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/*path omitted*/*project name omitted*/csx/Debug/roles/Azure.EnquiryWorker/approot/Microsoft.ServiceBus.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
StackTrace:
at Azure.EnquiryWorker.WorkerRole.OnStart()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRole(RoleType roleType)
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()
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()
InnerException:
webforms应用程序在bin文件夹中有serviceBus dll(作为间接引用添加,因为服务总线代码驻留在库项目中)。
GAC不包含servicebus程序集,我的项目都引用了servicebus dll的v2,并设置为CopyLocal。
答案 0 :(得分:2)
当我将Azure ServiceBus Nuget软件包更新到2.1版时,这个问题很方便了。
答案 1 :(得分:-1)
要帮助调试此问题,您是否可以在本地计算机上确认您是否在GAC中安装了Microsoft.ServiceBus.dll?还要检查该版本是否与您在项目中引用的版本不同。
答案 2 :(得分:-1)
您的项目似乎没有DLL或其正确版本。构建应用程序并查看/ bin文件夹。如果找到DLL(Microsoft.ServiceBus.dll),请检查版本并确保其匹配(版本= 2.0.0.0)。如果找不到它,它可能在您的全局程序集缓存中。
如果这对您没有帮助,请尝试: 1.在引用属性中设置copylocal = true,以便将DLL复制到输出目录中。 2.使用nuget包管理器链接到Microsoft.Servicebus dll。它通常解决了很多类似的问题。