在One.dll中有 using Two; namespace One { public SomeType { public void DoSomething(){ AnotherType.Hello(); } } }
在Two.dll中有 namespace Two { public AnotherType { public static void Hello(){} } }
Main.exe运行时,首先将One.dll与Two.dll安装到某一路径下,之后动态加载One.dll并调用一个方法 ... var path = "某路径\One.dll"; var assembly = Assembly.LoadFile(path); var type = assembly.GetType("One.SomeType"); var obj = Activator.CreateInstance(type); var method = type.GetMethod("DoSomething", BindingFlags.Public | BindingFlags.Instance); if (method != null) { method.Invoke(obj, null); } ...