我這樣做如下(我使用基類,用抽象方法代替接口):
1 - 列出用我的基類實現的類。
Assembly assembly = null;
AssemblyName assemblyName = new AssemblyName();
assemblyName.CodeBase = "FullPathToAssembly";
assembly = Assembly.Load(assemblyName);
Type[] arrayTipo;
arrayTipo = assembly.GetTypes();
var tipos =
from t in arrayTipo
where t.BaseType == typeof(DD.Util.BaseProcesso)
select t;
2 - 來電的類的實例執行的方法:
Type tipo = engine.GetType("FullClassName");
BaseProcesso baseProcesso = (BaseProcesso)Activaor.CreateInstance(tipo, new object[] { "ConstructorParameter1", "ConstructorParameter1") });
// Event
baseProcesso.IndicarProgresso += new BaseProcesso.IndicarProgressoHandler(baseProcesso_IndicarProgresso);
new Thread(new ThreadStart(baseProcesso.Executar)).Start();
對我的作品!