130 likes | 141 Views
Learn about .NET reflection, metadata retrieval, object creation, embedded resources, performance implications, security concerns, and essential tools in this comprehensive guide from Random Logic Forum .NET.
E N D
.NET reflection By Damián Laufer Forum .NET 3rd Meeting ● February 15, 2006 Random Logic l Forum .NET l 2006
Agenda • What is reflection • Getting metadata • Object creation / use • Embedded resources • Performance issues • Security (!) • Tools Random Logic l Forum .NET l 2006
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 2006
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 2006
(classes, interfaces, value types, enumeration types) Random Logic l Forum .NET l 2006
Object creation • Load assemblies dynamically • Create classes • Call members • Get events Random Logic l Forum .NET l 2006
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 2006
Embedded resources • Bitmaps • Icons • Cursors • Audio files • Video files • String tables Random Logic l Forum .NET l 2006
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 2006
Security – hang on! • Getting private metadata • Calling private methods • Changing private fields • Getting private events (*) • Creating private classes Random Logic l Forum .NET l 2006
Tools • MSIL Disassembler (Ildasm.exe) (.NET Framework) • Lutz Roeder's .NET Reflector Random Logic l Forum .NET l 2006
Questions? Random Logic l Forum .NET l 2006
Thank You Random Logic l Forum .NET l 2006