简体   繁体   English

VS2017 15.61.1-无法从Azure Functions(使用v2创建)中调用.net 4.6.1类库函数

[英]VS2017 15.61.1 - Unable to call .net 4.6.1 class library function from Azure Functions (created using v2)

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 . 我正在尝试从Azure Function App项目( 使用Function App v2模板创建 )中将类库( Target Framework .Net Framework 4.6.1 )与Target Framework作为.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. .net 4.6.1类库为System.Data.SqlClient v4.4.3安装了nuget包,以支持任何SQL操作。 I then call the SQL class library operation from Function App project. 然后,我从Function App项目中调用SQL类库操作。 Things compile properly but at run time I get following error: 事情编译正确,但在运行时出现以下错误:

Exception while executing function: DownloadEncryptedOrderFiles. 执行函数时异常:DownloadEncryptedOrderFiles。 SQLLib: Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. SQLLib:无法加载文件或程序集'System.Data.SqlClient,版本= 4.2.0.1,区域性=中性,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. 根据一些在线论坛上给出的建议,我还将SQLClient nuget包降级为4.4.0,但仍然无法正常工作。 Seems like the SQLClient dll does not get copied to the bin directory of functions and hence it fails at runtime. 似乎SQLClient dll无法复制到函数的bin目录,因此在运行时失败。 I am wondering if it is OK to reference a .net 4.6.1 project from Azure Functions? 我想知道是否可以从Azure Functions引用.net 4.6.1项目吗? If yes then what am I doing wrong. 如果是,那我在做什么错。

Here are the details of the runtime environment: 以下是运行时环境的详细信息:

  • VS - 2017, v15.6.1 VS-2017,v15.6.1

Installed Products: 已安装产品:

  • Azure App Service Tools v3.0.0 Azure应用服务工具v3.0.0
  • Azure Functions and Web Jobs Tools 15.0.40215.0 Azure函数和Web作业工具15.0.40215.0
  • Nuget Package Manager 4.6.0 Nuget软件包管理器4.6.0

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. 您说类库已安装System.Data.SqlClient v4.4.3,但错误消息说它找不到System.Data.SqlClient,Version = 4.2.0.1。 ¿Have you checked your packages references? ¿您是否检查过包裹参考? Maybe you are trying to reference the wrong version. 也许您正在尝试引用错误的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM