I have .NET Standard 2.1 class library, which includes an object-model with properties attributed with DataAnnotations. I'm consuming it from a v3 Azure Function targeting .NET Core 3.1. I'm able to use the library no problem from a .NET Core console app, but when I consume it from the Azure Function app I get this error at runtime:
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.
Interestingly, I don't get this error when populating the object-model, only when trying to serialize it to JSON.
I've tried adding the System.ComponentModel.Annotations nuget package to the functions project as well but it did not resolve the issue?
How do I fix the issue so the code can run?
I take it back, this answer, Azure Function, EF Core, Can't load ComponentModel.Annotations 4.2.0.0, did indeed fix my issue. I was hitting an exception on Assembly.Load in the CurrentDomain_AssemblyResolve function and thought I was still failing, but it looks like that's expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With