Prasanth Thyagarjan
Prasanth Thyagarjan

Reputation: 103

Could not load type 'Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager' from assembly 'Microsoft.Azure.WebJobs.Host

The application is in Azure Functions,

The error that we are getting from container Pod logs is "Could not load type 'Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager' from assembly 'Microsoft.Azure.WebJobs.Host, Version=3.0.26.0".

In our application version all of the dll ver is 3.0.30.0

enter image description here

In the "dll" folder of debug is having the version with 3.0.30.0

enter image description here

And in this version 3.0.30.0, it has the class "Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager"

enter image description here

Not sure, where this "assembly 'Microsoft.Azure.WebJobs.Host, Version=3.0.26.0" is coming from.

Upvotes: 3

Views: 9131

Answers (4)

Al Hawkins-Cole
Al Hawkins-Cole

Reputation: 11

I had a similar issue when we upgraded from:

"Microsoft.Azure.WebJobs" Version="3.0.31" to: "Microsoft.Azure.WebJobs" Version="3.0.39"

I tried the removal of the Azure Function Tools from the system path C:\Users\user.name\AppData\Local\AzureFunctionsTools and Let Visual Studio automatically install Azure Functions Core Tools fixed the issue, as suggested above.

This worked for the similar issue I was getting

Upvotes: 1

CodeConstruct
CodeConstruct

Reputation: 414

For me this was happening because Azure Functions Core Tools version mismatched due to upgradation of Visual Studio to latest version. Removing the Azure Function Tools from the system path C:\Users\user.name\AppData\Local\AzureFunctionsTools and Let Visual Studio automatically install Azure Functions Core Tools fixed the issue.

Upvotes: 5

ISP
ISP

Reputation: 63

I had the same issue as below log.

Could not load type 'Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager' from assembly 'Microsoft.Azure.WebJobs.Host, Version=3.0.25.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

It was due to my base image for azure functions was old. using the newer base image with below tag(mcr.microsoft.com/azure-functions/dotnet:3.4.2) has fixed my issue.

FROM mcr.microsoft.com/azure-functions/dotnet:3.4.2 AS base
WORKDIR /home/site/wwwroot
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:3.1.416 AS build
WORKDIR /src

Upvotes: 1

Rafal
Rafal

Reputation: 12629

This is not direct answer to your question but a tool that would answer it for you. As I had a lot of this kind of errors I have written a helper code to do just that. Its written for the .net framework but with minor changes you can have same thing on core.

       //folder where dependencies should be found
       var dir = @"C:\Repos\Project\bin"; 
       //dll or exe that you want to inspect
        var dll = @"C:\Repos\Project\bin\Project.dll"; 
        var asm = Assembly.ReflectionOnlyLoadFrom(dll);

        var stack = new Stack<Data>();
        stack.Push(new Data { 
           ReferencesPath = Array.Empty<Assembly>(), 
           Assembly = asm
        });
        List<AssemblyName> visited = new List<AssemblyName>();


        while (stack.Any())
        {
            var current = stack.Pop();
            var dependencies = current.Assembly.GetReferencedAssemblies();
            visited.Add(current.Assembly.GetName());
            foreach (var item in dependencies)
            {
                if (!visited.Any(x => x.FullName == item.FullName))
                {
                    Assembly dependency;
                    try
                    {
                        dependency = Assembly.ReflectionOnlyLoad(item.FullName);
                    }
                    catch
                    {
                        var path = Path.Combine(dir, item.Name) + ".dll";
                        dependency = Assembly.ReflectionOnlyLoadFrom(path);
                    }

                    if (dependency.GetName().Version != item.Version)
                    {
                        ; // put breakpoint here and inspect dependency 
   // and item when you find your dll in wrong version 
   // you can inspect current.ReferencesPath to see dependencies 
   // chain that causes the error
                    }

                    stack.Push(new Data
                    {
                        Assembly = dependency,
                        ReferencesPath = current.ReferencesPath.Concat(
new[] { current.Assembly }).ToArray()
                    });
                }
            }
        }



class Data
{
    public Assembly[] ReferencesPath { get; set; }
    public Assembly Assembly { get; internal set; }
}

Upvotes: 0

Related Questions