0

I am trying to reference a class library (Target Framework .Net Framework 4.6.1) from a Azure Function App project (created using Function App v2 template) with Target Framework as .Net Standard 2.0. The .net 4.6.1 class library has a nuget package installed for System.Data.SqlClient v4.4.3 to support any SQL operations. I then call the SQL class library operation from Function App project. Things compile properly but at run time I get following error:

Exception while executing function: DownloadEncryptedOrderFiles. SQLLib: Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

As per suggestions given on some online forums, I also downgraded SQLClient nuget package to 4.4.0, but it still does not work. Seems like the SQLClient dll does not get copied to the bin directory of functions and hence it fails at runtime. I am wondering if it is OK to reference a .net 4.6.1 project from Azure Functions? If yes then what am I doing wrong.

Here are the details of the runtime environment:

  • VS - 2017, v15.6.1

Installed Products:

  • Azure App Service Tools v3.0.0
  • Azure Functions and Web Jobs Tools 15.0.40215.0
  • Nuget Package Manager 4.6.0
Pankaj Vohra
  • 155
  • 2
  • 8
  • Google knows the problem, downgrade the nuget package to v4.4.0 – Hans Passant Mar 20 '18 at 18:23
  • I already tried downgrading to v4.4.0 of System.Data.SqlClient but it still does not work. – Pankaj Vohra Mar 20 '18 at 19:00
  • "I am wondering if it is OK to reference a .net 4.6.1 project from Azure Functions?" Functions v1, yes, but v2, no. The only thing targeting .NET Standard 2.0 does is guarantees that .NET Framework or .NET Core applications can use that netstandard library. It isn't meant to work the other way around. – McGuireV10 Mar 20 '18 at 19:33
  • Per my understanding, you'd better create a Class Library (.NET Standard) and reference the System.Data.SqlClient to wrap some SQL operations, then you could reference the net standard class library in your Function App v2 project. Or you could just directly reference System.Data.SqlClient in your Function App v2 project. – Bruce Chen Mar 21 '18 at 07:12

1 Answers1

-1

You say the class library has installed System.Data.SqlClient v4.4.3 but the error message says it can't find System.Data.SqlClient, Version=4.2.0.1. ¿Have you checked your packages references? Maybe you are trying to reference the wrong version.

jacdDev
  • 196
  • 1
  • 8