Random Logic l Forum.NET l NET reflection Forum.NET 3 rd Meeting ● February 15, 2006 By Damián Laufer
Random Logic l Forum.NET l Agenda What is reflection Getting metadata Object creation / use Embedded resources Performance issues Security (!) Tools
Random Logic l Forum.NET l What is Reflection? -A set of classes that allow you to access and manipulate assemblies and modules, and the types and the metadata that they contain.
Random Logic l Forum.NET l Getting metadata -Get metadata from an assembly -AssemblyName -Modules -Types (classes, interfaces, value types, enumeration types) -Members (constructors, methods, properties, fields, events) -Parameters
Random Logic l Forum.NET l (classes, interfaces, value types, enumeration types)
Random Logic l Forum.NET l Object creation -Load assemblies dynamically -Create classes -Call members -Get events
Random Logic l Forum.NET l Loading assemblies / types Assemblies Asm = Assembly.GetExecutingAssembly Asm = Assembly.LoadFrom(“path”) Asm = Assembly.load(“mscorlib”) Types Ty = asm.GetType(“Name”) Ty = GetType(String) Ty = anInstance.GetType Ty = Type.GetType(“System.Int32”)
Random Logic l Forum.NET l Embedded resources -Bitmaps -Icons -Cursors -Audio files -Video files -String tables
Random Logic l Forum.NET l Performance issues -Slower (muuuuuuch slower) -So, why should you use it? -Task manager -Data bound list view control -data row class loader (CRUD)
Random Logic l Forum.NET l Security – hang on! -Getting private metadata -Calling private methods -Changing private fields -Getting private events (*) -Creating private classes
Random Logic l Forum.NET l Tools -MSIL Disassembler (Ildasm.exe) (.NET Framework) -Lutz Roeder's.NET Reflector
Random Logic l Forum.NET l Questions?
Random Logic l Forum.NET l Thank You