Random Logic l Forum.NET l 20061.NET reflection Forum.NET 3 rd Meeting ● February 15, 2006 By...
-
Upload
cecil-august-fitzgerald -
Category
Documents
-
view
217 -
download
0
Transcript of Random Logic l Forum.NET l 20061.NET reflection Forum.NET 3 rd Meeting ● February 15, 2006 By...
Random Logic l Forum .NET l 2006 1
.NET reflection
Forum .NET 3rd Meeting ● February 15, 2006
By Damián Laufer
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
TThank Youhank You