【发布时间】:2020-12-17 03:06:23
【问题描述】:
我有 .NET Standard 2.1 类库,其中包括一个对象模型,该对象模型具有使用 DataAnnotations 属性的属性。我正在从针对 .NET Core 3.1 的 v3 Azure 函数中使用它。我可以从 .NET Core 控制台应用程序中毫无问题地使用该库,但是当我从 Azure Function 应用程序中使用它时,我在运行时收到此错误:
System.Private.CoreLib: Exception while executing function: ... System.Private.CoreLib: Could not load file or assembly 'System.ComponentModel.Annotations, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
有趣的是,填充对象模型时我没有收到此错误,只有在尝试将其序列化为 JSON 时。
我也尝试将 System.ComponentModel.Annotations nuget 包添加到函数项目中,并尝试了针对类似问题的建议修复,例如 https://stackoverflow.com/a/44079161/892770 和 https://stackoverflow.com/a/50776946/892770,但无济于事。
有什么想法吗?谢谢!
【问题讨论】:
标签: c# azure .net-core azure-functions