无法从程序集“Microsoft.Azure.WebJobs.Host”加载类型“Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager”

问题描述 投票:0回答:4

应用程序位于 Azure Functions 中,

我们从容器 Pod 日志中收到的错误是“无法从程序集“Microsoft.Azure.WebJobs.Host,版本=3.0.26.0”加载类型“Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager”。

在我们的应用程序版本中,所有 dll 版本都是 3.0.30.0

在debug的“dll”文件夹中有3.0.30.0的版本

在这个版本3.0.30.0中,它有类“Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager”

不确定这个“程序集'Microsoft.Azure.WebJobs.Host,Version = 3.0.26.0”来自哪里。

c# kubernetes .net-core azure-functions azure-aks
4个回答
5
投票

对我来说,发生这种情况是因为由于 Visual Studio 升级到最新版本,导致 Azure Functions Core Tools 版本不匹配。 从系统路径中删除 Azure Function Tools

C:\Users\user.name\AppData\Local\AzureFunctionsTools
并让 Visual Studio 自动安装 Azure Functions Core Tools 解决了该问题。


1
投票

我遇到了与以下日志相同的问题。

无法从程序集“Microsoft.Azure.WebJobs.Host,Version=3.0.25.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”加载类型“Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager”。

这是因为我的 azure 函数的基础镜像很旧。使用带有以下标签的新基本图像(

mcr.microsoft.com/azure-functions/dotnet:3.4.2
)解决了我的问题。

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

0
投票

这不是对您问题的直接回答,而是一个可以为您解答问题的工具。由于我遇到了很多此类错误,因此我编写了一个辅助代码来做到这一点。它是为 .net 框架编写的,但只需稍作更改,您就可以在核心上拥有相同的东西。

       //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; }
}

0
投票

当我们升级时我遇到了类似的问题: “Microsoft.Azure.WebJobs”版本=“3.0.31”到:“Microsoft.Azure.WebJobs”版本=“3.0.39”

我尝试从系统路径 C:\Users\user.name\AppData\Local\AzureFunctionsTools 中删除 Azure Function Tools,并让 Visual Studio 自动安装 Azure Functions Core Tools 修复了问题,如上所述。

这适用于我遇到的类似问题

© www.soinside.com 2019 - 2024. All rights reserved.