unity-game-enginemulti-layer

assembly reference in multi layer C# project


My multi layer project has Datalayer, services, panel. dataLayer referenced to services, and services referenced to panel. i have an interface in datalayer, some thing like

public interface IJournalEntity
{
   ...
}

my services has a class that inherited from IJournalEntity,

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

when i compile panel layer, unity config raise an error to add reference to data layer, how could i fix withoud referenced that?


Solution

  • You cannot fix without referenced that. The type is unknown to your project if you don't reference it.

    Some similar questions:

    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

    If your datalayer is defined in a separate dll, you need to put that in Assets/Plugins/. This applied to Unity3D 4.x. On Unity3D 5.x, just put the dll in Assets will work.