你好
我有一个主应用程序,它将在./plugin目录中拥有一些插件。
每个插件都是一个.NET dll文件,应该具有命名空间"Plugin"和一个实现了主应用程序中定义的IPlugin接口的"MainClass"类。
我的问题是,我不知道如何在主应用程序和每个插件之间共享相同的接口,而不需要使用
我有一个主应用程序,它将在./plugin目录中拥有一些插件。
每个插件都是一个.NET dll文件,应该具有命名空间"Plugin"和一个实现了主应用程序中定义的IPlugin接口的"MainClass"类。
我的问题是,我不知道如何在主应用程序和每个插件之间共享相同的接口,而不需要使用
using
引用?
主应用程序类的一部分:
object oo = Assembly.LoadFile(path).CreateInstance("Plugin.MainClass");
IPlugin pp = (IPlugin)oo; //Fails if I define the interface in the main app and the plugins
同时也是第一个插件的一部分:
namespace Plugin
{
public class MainClass : IPlugin //I cannot reference the interface in the main app?
{
public string getName()
{
return "Plugin 1";
}
}
}