我创建了几个 .Net Standard 2.0 库,通过控制台应用程序测试了执行,以及几个测试 - 一切都很好.
I have created several .Net Standard 2.0 libraries, tested the execution via a console application, as well as several tests - all is good.
移动到 azure 函数,并得到以下运行时错误:
Move over to azure function, and get the following run-time error:
然后我尝试将该特定版本下载到 API Function 项目中:
I then try to download that specific version into the API Function project:
我正在使用 Visual Studio 15.7.0 预览版 5.0.我已将 Azure Function 更新到 4.7...,因为控制台和测试项目是 - 并且这些工作正常.
I'm using Visual Studio Version 15.7.0 Preview 5.0. I have updated the Azure Function to 4.7... as the console and test projects are - and those work.
已经在这个太多小时.. 所以我希望决议不是什么疯狂.Ef Core 2.1.0-rc1-final 也在其中.对Required、MaxLength、NotMapped 使用数据注解.
Been at this a far too many hours.. so I'm hoping the resolution isn't something crazy. Ef Core 2.1.0-rc1-final is also in the mix. Using data annotations for Required, MaxLength, NotMapped.
图形错误 说:Microsoft.EntityFrameworkCore:无法加载文件或程序集System.ComponentModel.Annotations,版本=4.2.0.0
Error in graphic says: Microsoft.EntityFrameworkCore: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0
我建议在启动 Azure Function 后在下面运行此函数.它将任何程序集重定向到现有版本.
I would suggest running this function below once you start your Azure Function. It will redirect any assembly to an existing version.
public class FunctionsAssemblyResolver
{
public static void RedirectAssembly()
{
var list = AppDomain.CurrentDomain.GetAssemblies().OrderByDescending(a => a.FullName).Select(a => a.FullName).ToList();
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
var requestedAssembly = new AssemblyName(args.Name);
Assembly assembly = null;
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
try
{
assembly = Assembly.Load(requestedAssembly.Name);
}
catch (Exception ex)
{
}
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
return assembly;
}
}
这篇关于Azure 函数,EF Core,无法加载 ComponentModel.Annotations 4.2.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!