gpt4 book ai didi

c# - Azure Functions - 无法加载文件或程序集 '' AzureFunctions.Autofac.Shared'

转载 作者:行者123 更新时间:2023-12-03 04:49:51 25 4
gpt4 key购买 nike

我有 Azure Functions 项目,并且正在使用 Autofac dll 在 Azure 函数中进行 DI。尝试使用 VS 2017(社区)运行该函数时,它抛出异常 -

System.IO.FileNotFoundException: 'Could not load file or assembly 'AzureFunctions.Autofac.Shared, Version=3.0.6.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

我尝试解决问题的方法 -

  1. 卸载“AzureFunctions.Autofac”NuGet 数据包并重新安装。
  2. 重新启动 VS 甚至我的机器
  3. 确保我已安装 Azure 存储模拟器和 Azure CLI。
  4. 检查所有“AzureFunctions.Autofac”NuGet 包是否已正确加载到项目中。
  5. 尝试在 Google 上搜索,但找不到具体的解决方案。

这里可能出了什么问题以及如何调试这个问题?

谢谢!

最佳答案

我也尝试过 3.0.6 版本,它有效。以下是我的解决方案的一些屏幕截图,供引用:

enter image description here enter image description here

public class DIConfig
{
public DIConfig(string functionName)
{
DependencyInjection.Initialize(builder =>
{
builder.RegisterType<NaiveInvestementAllocator>().As<IInvestementAllocator>(); // Naive

}, functionName);
}
}

enter image description here

还要确保您拥有 Nuget Document 中提到的所有必需依赖项

enter image description here

关于c# - Azure Functions - 无法加载文件或程序集 '' AzureFunctions.Autofac.Shared',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54826130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com