public MainWindow() { InitializeComponent(); var files = Directory.GetFiles(".", "G9PX_*.dll"); string where = Directory.GetCurrentDirectory(); AppDomain ad = AppDomain.CreateDomain("TestDomain1"); ITypeFinder tt = (ITypeFinder)ad.CreateInstanceFromAndUnwrap(where + "/" + "LoadAssemblyHelpers.dll", "LoadAssemblyHelpers.TypeFinder"); //ITypeFinder tz = (ITypeFinder)ad.CreateInstanceAndUnwrap("LoadAssemblyHelpers.dll", "LoadAssemblyHelpers.TypeFinder"); //ad. string result = tt.WhatAmI(); string otherResult = tt.WhereAmI(); foreach (string file in files) { var item = Assembly.LoadFile(where + "/" + file); System.Type[] stuff = item.GetExportedTypes(); MyTestInterface myObject = (MyTestInterface)Activator.CreateInstance(stuff[0]); string name = myObject.TestMethod(); //var otherItem = Assembly.LoadFrom(file); } }
public void TestProxy() { InvocationHandler handler = new MyHandler(); MyTestInterface inter = (MyTestInterface)Proxy.NewProxyInstance(typeof(MyTestInterface), handler); Assert.AreEqual("TestTwoArgs foo bar", inter.TestTwoArgs("foo", "bar")); IList <object> temp = new List <object>(); inter.TestVoid(temp); Assert.AreEqual("my void result", temp[0]); Assert.AreEqual(10, inter.TestPrimitive(10)); Assert.AreEqual(1000L, inter.TestStruct(new DateTime(1000)).Ticks); inter.TestProperty = "my property"; Assert.AreEqual("my property", inter.TestProperty); }