Assembly ass;
ass = System.Reflection.Assembly.Load("TestLibrary");
obj = ass.CreateInstance("TestLibrary.TestForm");//必须使用名称空间+类名称
obj = ass.CreateInstance("TestLibrary2.Form1");
首先我已经生成了2个dll 一个是TestLibrary 还有一个TestLibrary2。并且TestLibrary引用了TestLibrary2。
那么请问反射里load方法有一句话,通过这个方法加载的程序集比如TestLibrary,那么它会同时加载该程序集引用的程序集。
那么为什么我测试上面的代码的时候
执行到obj = ass.CreateInstance("TestLibrary.TestForm");这个是成功了
执行到obj = ass.CreateInstance("TestLibrary2.Form1");失败了。
(注,这里的窗体类都是有的)