0
votes

I am implementing azure service bus functionality into a clients asp.net webforms solution.

a worker role polls the bus periodically for new messages, and a web role is defined for the existing webforms app, which is responsible for adding putting messages on the bus queue.

Whenever i try to run the app locally i get an error due to the Microsoft.ServiceBus assembly being a mismatch from the expected...

 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: 

The webforms app has the serviceBus dll in the bin folder (which is added as an indirect reference, as the service bus code resides in a library project).

The GAC contains no servicebus assemblies, my projects are all referencing v2 of the servicebus dll, and are set to CopyLocal.

3

3 Answers

2
votes

This problem conveniently went away when i updated the Azure ServiceBus Nuget package to version 2.1.

-1
votes

To help debug this can you confirm on your local machine if you have Microsoft.ServiceBus.dll in the GAC? Also check if that version is different from what you have referenced in the project.

-1
votes

It seems like your project does not have the DLL, or a correct version of it. Build the applicaiton and look in the /bin folder. If you find the DLL (Microsoft.ServiceBus.dll), check the version and make sure it matches (Version=2.0.0.0). If you can't find it, it might be in your Global Assembly Cache.

If this doesn't help you, try: 1. Set copylocal = true in your reference properties so that the DLL is copied into your output directory. 2. Use nuget package manager to link to the Microsoft.Servicebus dll. It usually solves a lot of similar problems.