Alexander
Alexander

Reputation: 1829

Could not load file or assembly 'System.Data.Entity 4.0.0.0 in azure function referencing a class library

Getting this error:

System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. Source=... StackTrace: at ....

I create an azure function referencing a class library.

I checked on the class library, System.Data.Entity is being referenced. But when I run the azure function, I get this error.

What might be wrong here?

The Azure function is on .Net Core 3.1. The referenced class library (as a project so I can debug it) is on .Net Framework 4.7.2

Is a class library of .net Framework 4.7.2 supported when referenced on .net Core 3.1 (why its not loading System.Data.Entity)?

Upvotes: 1

Views: 1852

Answers (1)

Frank Borzage
Frank Borzage

Reputation: 6796

From this post we can know:

.NET Core doesn't support inclusion of .NET Framework libraries. Period. However, .NET Core supports .NET Standard, and since .NET Framework also implements .NET Standard, Microsoft made a special exception in the compiler to allow you include .NET Framework libraries, with the caveat that they may not actually function at all or totally. You get a warning to this effect when you include a .NET Framework library in a .NET Core project, and it's on you to ensure that the library works correctly end-to-end.

Because .NET Core supports .NET Standard library, you can use the package of .NET Standard. This post is similar to your problem, his solution may inspire you.

Upvotes: 1

Related Questions