namespace cl1 { public class Class1 { public int Test() { cl2.Class2 c2 = new cl2.Class2(); return 2 * c2.Test(); } } }
namespace cl2 { public class Class2 { public int Test() { return 10; } } }
private void button1_Click(object sender, EventArgs e) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler( CurrentDomain_AssemblyResolve); Assembly asm = Assembly.LoadFile( @"C:\temp\WindowsFormsApplication9\cl1\bin\Debug\cl1.dll"); Type t = asm.GetType("cl1.Class1"); object o = Activator.CreateInstance(t); MethodInfo mi = t.GetMethod("Test"); int sonuc = (int)mi.Invoke(o,null); } Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Assembly asm = Assembly.LoadFile( @"C:\temp\WindowsFormsApplication9\cl1\bin\Debug\" +args.Name.Split(',')[0]+".dll"); return asm; }