多层 C# 项目中的程序集引用

assembly reference in multi layer C# project

我的多层项目有数据层、服务、面板。数据层引用服务,服务引用面板。我在数据层中有一个接口,类似于

public interface IJournalEntity
{
   ...
}

我的服务有一个 class 继承自 IJournalEntity,

public class OfflinePaymentService : IOfflinePaymentService, IJournalEntity
{
...                
}

当我编译面板层时,unity 配置引发错误以添加对数据层的引用,我该如何解决没有引用的问题?

如果不参考它,您将无法修复。如果您不引用该类型,您的项目将不知道该类型。

一些类似的问题:

  1. Access interface methods without referring the class
  2. C# Use a class that implements an interface without adding a reference to the assembly that defines the interface

如果您的数据层是在单独的 dll 中定义的,则需要将其放入 Assets/Plugins/。这适用于 Unity3D 4.x。 在 Unity3D 5.x 上,只需将 dll 放入 Assets 即可。