Dotfuscator User's Guide
Running the Reflection Sample

The reflection sample can be run by executing the Reflection.exe assembly produced by the make.bat command. The reflection program dynamically loads a class from the current assembly with the following code:

Reflection Sample Code
Copy Code
  //get the requested type from current assembly
   assembly = this.GetType().Assembly;
   type = assembly.GetType(typename, true);
   instance = Activator.CreateInstance(type);

It is worth noting that the class that is loaded is specified by the string variable typename. Looking closer at the sample code shows us that typename is initialized to the value Samples.Greeting.

Further on in the program, the SayGreetings method of Samples.Greeting is invoked dynamically with similar code:

Sample.Greeting Code
Copy Code
   MethodInfo method = type.GetMethod(methodname);

As its name suggests, the SayGreetings method displays some friendly messages on the console:

SayGreetings Friendly Messages
Copy Code
Hello Bob!
Goodbye Bob!



© 2016 PreEmptive Solutions, LLC. All Rights Reserved.