Christmas! A Time for Reflection!
... or Arbor Day or Guy Fawkes Day or Bastille Day. In fact, for the VB.NET programmer, every day is a good day for reflection. That's because reflection is one of the most valuable new techniques introduced by .NET. But since there was nothing like this in VB 6, reflection is also one of those concepts that a lot of VB 6 programmers often have difficulty with. In fact, an informal survey of the books in my personal VB.NET library (about fifty or so) reveals that only a few actually have anything to say about it. (One of the best, by the way, is Paul Kimmel's "Visual Basic .NET Unleashed". Paul has included an entire chapter about reflection. Wrox also published the "Visual Basic .NET Reflection Handbook" in 2002 but this book can be difficult to find today.) To set this situation to right, About Visual Basic has added a new article to introduce you to the techniques available using reflection.
Part of the problem, as usual, is that a lot of what you can find about reflection is just too hard to understand. For example, here's the definition that you can find at Microsoft's MSDN site:
"The System.Reflection namespace contains classes and interfaces that provide a managed view of loaded types, methods, and fields, with the ability to dynamically create and invoke types."
Now isn't that just special! Armed with this flawlessly clear explanation, I'm sure we can all start using reflection in all of our programs now. Not!
Even pages that try to reduce the 'fog factor' sometimes miss the mark. Here's one of those:
"Reflection is the process of walking the metadata about a type and finding out things."
I know about walking the dog. That's a good way to find out things too. But somehow I don't think it applies here.
Here's my attempt at a short, comprehensible definition:
Reflection provides ways to let your program get, change, or create information about programs at run time.
For example, if you need to know the path that your program was loaded from so you can retrieve other files from the same path? Reflection does it! Are 'resources' such as bit maps or XML files included into the executable of your program? Reflection will retrieve them. Read this article to learn just how it's done!


Comments
Thank you. your article was informative and funny. Now i know a lot about reflections.
Great!!
Very Simple language, and very informative
Thank u sir