引用.Net Core中的另一个项目 [英] Referencing another project in .Net Core

查看:493
本文介绍了引用.Net Core中的另一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个空白解决方案中,我有6个项目.我只想引用一个项目到另一个.我在 Blog.Web 项目中有HomeController.我想访问另一个项目的方法,例如 Blog.Services 项目中的IOrganizationService.如何在HomeController类中使用IOrganization的方法?要获得清晰的见解,请参见图片.

I have 6 projects in a blank solution. I just want to reference a project to another. I have HomeController in Blog.Web projects. I want to access another project's methods like IOrganizationService in Blog.Services projects. How can I use IOrganization's method in HomeController class? For clear insight, please see picture.

红色标记显示错误....

Red marks show the errors....

推荐答案

看起来就像您已经将所有内容创建为网站一样,但我怀疑认为这些项目中的大多数实际上应该是类库(dll),而不是站点.您可能需要重置一些东西!

It looks like you've created everything as web sites, but I suspect that most of those projects should actually be class libraries (dlls), not sites. You might need to reset a few things!

您应该能够右键单击Dependencies节点以添加项目引用:

You should be able to right-click on the Dependencies node to add a project reference:

或项目节点:

然后:

或者:编辑csproj并添加一个<ProjectReference>节点:

Alternatively: edit the csproj and add a <ProjectReference> node:

这篇关于引用.Net Core中的另一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆