1 / 13

.NET reflection

.NET reflection. By Damián Laufer. Forum .NET 3 rd Meeting ● February 15, 2006. Agenda. What is reflection Getting metadata Object creation / use Embedded resources Performance issues Security (!) Tools. What is Reflection?.

eashford
Télécharger la présentation

.NET reflection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .NET reflection By Damián Laufer Forum .NET 3rd Meeting ● February 15, 2006 Random Logic l Forum .NET l 2006

  2. Agenda • What is reflection • Getting metadata • Object creation / use • Embedded resources • Performance issues • Security (!) • Tools Random Logic l Forum .NET l 2006

  3. 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

  4. 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

  5. (classes, interfaces, value types, enumeration types) Random Logic l Forum .NET l 2006

  6. Object creation • Load assemblies dynamically • Create classes • Call members • Get events Random Logic l Forum .NET l 2006

  7. 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

  8. Embedded resources • Bitmaps • Icons • Cursors • Audio files • Video files • String tables Random Logic l Forum .NET l 2006

  9. 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

  10. 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

  11. Tools • MSIL Disassembler (Ildasm.exe) (.NET Framework) • Lutz Roeder's .NET Reflector Random Logic l Forum .NET l 2006

  12. Questions? Random Logic l Forum .NET l 2006

  13. Thank You Random Logic l Forum .NET l 2006

More Related