Why does assembly binding fail in my project?

2

I am working on an Azure function project in a Class Library project that targets .NET Standard 2.0. I am using the following assemblies, shown below. Beside each one, I've included its dependency requirement of the version of Microsoft.Azure.Webjobs.

"Microsoft.Azure.Functions.Extensions" Version="1.0.0" />  Azure.Webjobs needed: >=3.0.5
"Microsoft.Azure.WebJobs.Extensions" Version="3.0.6" /> Azure.Webjobs needed: >=3.0.14
"Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.2" /> Azure.Webjobs needed: >=3.0.2
"Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.2" /> Azure.Webjobs needed: >=3.0.16

I have installed Microsoft.Azure.Webjobs v3.0.22 which (seemingly) satisfies all the above requirements. Yet when I run my application repeatedly, the runtime alternates between the following errors:

Could not load file or assembly **'Microsoft.Azure.WebJobs.Host,
Version=3.0.14.0**, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The located assembly's manifest definition
does not match the assembly reference.  Source Error:

Calling assembly : **Microsoft.Azure.WebJobs.Extensions,
Version=3.0.6.0**,

And this one:

Could not load file or assembly '**Microsoft.Azure.WebJobs.Host,
Version=3.0.5.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)

SCalling assembly : **Microsoft.Azure.Functions.Extensions,
Version=1.0.0.0**, Culture=neutral, PublicKeyToken=f655f4c90a0eae19.

Why is the runtime trying to bind to these lower versions of Microsoft.Azure.Webjobs? Why not just use v.3.0.22 which satisfies the requirements listed in Nuget for Webjobs.Extensions and Functions.Extensions?

c#
.net
azure
asked on Stack Overflow Oct 3, 2020 by DalhousieDuck • edited Oct 3, 2020 by Svirin

1 Answer

1

There should be some other assembly that is using the old version of Host, try to add the binding redirect to your config

<dependentAssembly>
    <assemblyIdentity name="Microsoft.Azure.WebJobs.Host" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="3.0.14.0" newVersion="3.0.22.0"/>
</dependentAssembly>
answered on Stack Overflow Oct 3, 2020 by svyatis.lviv

User contributions licensed under CC BY-SA 3.0