usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Reflection;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacewinfrom{ Public Partial classForm4:form { PublicForm4 () {InitializeComponent (); } Private voidForm4_load (Objectsender, EventArgs e) {Assembly asm= Assembly.Load ("Winfrom"); varType = asm. GetType ("winfrom.test"); varInstance = asm. CreateInstance ("winfrom.test"); Type. GetProperty ("Name"). SetValue (instance,"Hello World",NULL); Type. GetProperty ("Id"). SetValue (instance,1,NULL); varmethod = Type. GetMethod ("Hello"); Method. Invoke (instance,NULL); } } Public classTest {Private intID; Private stringname; Public intId {Get{return This. ID;} Set{ This. ID =value;} } Public stringName {Get{return This. Name; Set{ This. Name =value;} } Public voidHello () {MessageBox.Show (Name); } }}
Assembly (Assembly)