为什么找不到我的界面?

B. *_*non 0 c# projects-and-solutions interface solution asp.net-mvc-4

我得到,“找不到类型或命名空间名称‘INRBQDeliveryRepository’(您是否缺少 using 指令或程序集引用?)”在这里:

public class DeliveryController : ApiController
{
    private readonly INRBQDeliveryRepository _deliveryRepository;
Run Code Online (Sandbox Code Playgroud)

我试图引用的接口类型是:

namespace SeaStore.Data.Legacy.Interfaces
{
    public interface INRBQDeliveryRepository
    . . .
Run Code Online (Sandbox Code Playgroud)

这些是解决方案中的不同项目(NRBQ.Web 正在尝试访问其兄弟 SeaStore.Data.Legacy);添加“使用 SeaStore.Data.Legacy.Interfaces;” 使用“未找到”错误阻止编译的类没有帮助 - 事实上,我从上面提到的错误转到获得附加错误,特别是:

类型或命名空间名称 'Data' 在命名空间 'SeaStore' 中不存在(您是否缺少程序集引用?) ”在此处的 Controller 类中:

using SeaStore.Data.Legacy.Interfaces;
Run Code Online (Sandbox Code Playgroud)

为什么我的其他项目界面不可见?

Mat*_*ijs 5

您收到的错误消息是一种不言自明的:are you missing an assembly reference

它表明您实际上缺少对程序集的引用。

添加 --> 引用 --> 找到定义您的接口的库,并添加引用。

然后 using 应该自行解决,因为它现在可以找到命名空间。这意味着您可以使用您的界面!