简体   繁体   English

在 Azure Function 项目中添加对类库的引用导致未找到程序集

[英]Adding Reference to Class LIbrary in Azure Function project causes assembly not found

I dont really have much to go on here, but I have an Azure Function project (.NET Core 3.1 with Azure Functions v3)我真的没有太多事情要做,但我有一个 Azure Function 项目(.NET Core 3.1 with Azure Functions v3)

This function has a Http Trigger which works perfectly on its own这个函数有一个 Http 触发器,它自己完美地工作

However, as soon as I reference one of my existing projects, I get the error但是,一旦我引用了我现有的项目之一,就会收到错误消息

    System.Private.CoreLib: Exception while executing function: MyFunction. 
FunctionApp2: Could not load file or assembly 'Microsoft.Extensions.Primitives, 
Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Is this related to assembly binding?这与程序集绑定有关吗? How can I force this version to be available to my function application?如何强制此版本可用于我的函数应用程序?

I dont have a web.config so the standard assembly binding wont work我没有 web.config 所以标准程序集绑定不起作用

Below is the file下面是文件

在此处输入图片说明

I have tried adding the assembly directly to the project and that makes no difference我曾尝试将程序集直接添加到项目中,但没有任何区别

The project I am referencing doesnt have this package either so I am not sure which package this comes from我引用的项目也没有这个包,所以我不确定它来自哪个包

My function app has the following packages我的函数应用有以下包

<ItemGroup>
       <PackageReference Include="Fody" Version="6.5.1">
         <PrivateAssets>all</PrivateAssets>
         <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       </PackageReference>
       <PackageReference Include="LoadAssembliesOnStartup.Fody" Version="4.5.0">
         <PrivateAssets>all</PrivateAssets>
         <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       </PackageReference>
       <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.3.0" />
      <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
  </ItemGroup>

I tried to use Fody to ensure that the referenced project assembly is loaded on startup but that made no difference我尝试使用 Fody 来确保在启动时加载引用的项目程序集,但这没有任何区别

As soon as I remove my other project it works fine一旦我删除了我的其他项目,它就可以正常工作

Paul保罗

I found the problem eventually, there is an issue with Redis and Azure Functions我最终找到了问题,Redis 和 Azure Functions 存在问题

I had to downgrade Redis and it worked我不得不降级Redis并且它起作用了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 添加对类库的引用 - adding reference to class library 为什么我们需要将类库项目继承的程序集的引用添加到使用者项目中? - Why do we need to add a reference to an assembly, from which a class library project inherits, into a consumer project? 在我的Azure函数中引用c#类库 - Reference c# class library in my Azure Function Azure 函数类库的 .NET Core 3.1 传递引用问题 - .NET Core 3.1 Transitive Reference Issue With Azure Function Class Library VSIX扩展将程序集引用添加到项目 - VSIX extension adding assembly reference to project 如何在不添加对类库的引用的情况下访问另一个类库中的视图模型和项目模型 - How to access view models and models of project in another class library without adding reference to the class library 发布 Blazor 项目,库项目参考 Azure - Publish Blazor project with library project reference to Azure 直接参考一个Razor Class库组件 - Reference directly a Razor Class Library assembly 将.NET Core类库引用添加到UWP应用时,显示“无法添加对项目的引用…”。 - When adding .NET Core class library reference to UWP app, it says “Unable to add a reference to project…” 嵌入在主应用程序找不到的类库中的程序集 - Assembly Embedded In Class Library Not Found By Main Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM