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

3
应用程序在Azure Functions中。
我们从容器Pod日志中得到的错误是“无法从程序集'Microsoft.Azure.WebJobs.Host,版本=3.0.26.0'中加载类型'Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager'”。
在我们的应用程序版本中,所有dll版本都是3.0.30.0。

enter image description here

在调试的 "dll" 文件夹中有版本为 3.0.30.0 的文件。

enter image description here

在这个版本3.0.30.0中,它拥有类"Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManager"。

enter image description here

我不确定这个 "assembly 'Microsoft.Azure.WebJobs.Host, Version=3.0.26.0" 是从哪里来的。

3个回答

5
对我来说,这是因为由于将Visual Studio升级到最新版本,Azure Functions Core Tools版本不匹配。 从系统路径C:\ Users \ user.name \ AppData \ Local \ AzureFunctionsTools 中删除Azure Function Tools,并让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

您能否重新表达您的回答,并更具体地说明关键字,比如 Azure Functions 的基础镜像?另外,也能帮忙解释一下这些命令吗? - CodeConstruct
@CodeConstruct,上面的示例展示了在容器中运行Azure函数的Dockerfile。基础镜像和所有术语都是特定于Dockerfile的。 - ISP
非常感谢。我经过一些深入了解后得知这个信息。 - CodeConstruct

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接