我为什么要添加对DLL的引用?

Dmi*_*ets 1 .net c#

奇怪的,可能是琐碎的问题.我在一个解决方案中有三个项目(.NET 2.0,Visual Studio 2005,C#).第一个产生GenericService.dll,它包含一个名为GenericService的抽象泛型类:

public abstract class GenericService< T > { } 
Run Code Online (Sandbox Code Playgroud)

第二个是ServiceImplementation.dll,它包含继承GenericService的ServiceImplementation类:

public class ServiceImplementation : GenericService< SomeType > { }
Run Code Online (Sandbox Code Playgroud)

第三个是使用ServiceImplementation的Windows应用程序:

ServiceImplementation si = new ServiceImplementation();
Run Code Online (Sandbox Code Playgroud)

所以ServiceImplementation项目引用了GenericService项目,而windows应用程序项目引用了ServiceImplementation项目.这个windows应用程序无法编译,需要引用GenericService.

为什么?我怎么解决这个问题?

Jam*_*mes 8

添加对GenericService的引用....

您的应用程序已经引用了ServiceImplementation,但是,如果它直接访问GenericService中的任何类/方法,那么它必须具有直接引用.