简体   繁体   English

Visual Studio中的Azure函数 - 如何添加对另一个项目的引用

[英]Azure Functions in Visual Studio - How to add reference to another project

I have created an Azure Function project in Visual Studio. 我在Visual Studio中创建了一个Azure Function项目。 I am trying to reference an entity framework model project that we already use. 我试图引用我们已经使用的实体框架模型项目。 Someone that is no longer with the company has accomplished this feat as you can see in the image below: 不再与公司合作的人已完成此专长,如下图所示:

在此输入图像描述

However when trying to create a new project, I am unable to add this project reference. 但是,在尝试创建新项目时,我无法添加此项目引用。 I am able to add the project to the solution normally (right clicking the solution file and clicking "Add Project", however I am unable to reference any of the code from that project inside of the azure function code. 我能够正常地将项目添加到解决方案中(右键单击解决方案文件并单击“添加项目”,但是我无法在azure功能代码中引用该项目中的任何代码。

在此输入图像描述

As you can see there is no "Projects" drop down, and there is no option in the context menu that corresponds to adding projects. 正如您所看到的,没有“项目”下拉列表,并且上下文菜单中没有与添加项目相对应的选项。

The azure project is v2 using netcoreapp2.1, whereas the project I wish to reference is net4.6 使用netcoreapp2.1的azure项目是v2,而我想参考的项目是net4.6

Any help would be greatly appreciated. 任何帮助将不胜感激。

Azure Functions V2 can only reference NetCore compatible projects, if you want an external library to be referenced in your Functions project, you need to declare that library as either a .NetCore or even .NetStandard library. Azure Functions V2只能引用与NetCore兼容的项目,如果要在Functions项目中引用外部库,则需要将该库声明为.NetCore或.NetStandard库。 A project built on Net4.6 is just too old to be referenced in a .NetCore project. 在Net4.6上构建的项目太旧了,无法在.NetCore项目中引用。

It look like the first Azure function that was able to reference the project was a version 1 azure function written in .Net 4.62 or so. 看起来第一个能够引用该项目的Azure功能是用.Net 4.62左右编写的版本1 azure函数。

Your V2 function being .net Core would not be able to reference a .net project/assembly that was written in a 4.xx version of .Net. 您的V2函数是.net Core将无法引用以.xx版本的.Net编写的.net项目/程序集。

Thanks, Gary 谢谢,加里

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

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