Search code examples
azureazure-web-rolesservicebusazureservicebus

Failing to load ServiceBus Assembly when debugging


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.


Solution

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