First, create an internal library project Cao. assemby. mydll and add a class mytest as follows:
Mytest. CS
NamespaceCao. assemby. mydll {Public classMytest{Public StringTest (){Return"My wife, I love you! ";}}}
Add a consoleProgram: Cao. assemby. Test, and add the file Cao. assemby. mydll in the library Cao. assemby. mydll.
To the project;
Namespace Cao. assemby. Test { /// <Summary> /// Instantiate objects directly and use reflection to instantiate objects /// </Summary> Class Program { Static void Main ( String [] ARGs) {refload (); // AA (); } /// <Summary> /// Load Assembly directly /// </Summary> Public static void AA () {mydll. Mytest T = New Cao. assemby. mydll. Mytest (); Console . Writeline (T. Test ());} /// <Summary> /// Instantiate an object Using Reflection /// </Summary> Public static void Refload () {assemby. mydll. Mytest T = (assemby. mydll. Mytest ) System. reflection. Assembly . Load ( "Cao. assemby. mydll" ). Createinstance ( "Cao. assemby. mydll. mytest" );Console . Writeline (T. Test ());}}}