共用方式為


Now I get it... Almost. Finally.

 In my time working with .NET, I feel I have only scratched the surface of the multitude of APIs available to us. One of the groups of APIs that I had, until recently, only scratched the surface of is reflection. I thought I knew the FL350 (for plane buffs like myself, that is our way of saying 35000 ft standard pressure) overview of reflection. I am now guessing I was much further away... In some respects, I feel that I was one of the Apollo astronauts -- well, at least when it comes to reflection.

 These days I am working with some dynamically generated code, so you either figure out how reflection works, or you will have to find something else to do. In this process, I have been so far out on tangents that I don't really want to think of what brought me there.

 I guess what I can conclude is this: Working with reflection is a little more cumbersome than working with ordinary "known" types, but definitely not insurmountable. When working with reflection, you will most likely get some exceptions like MissingMethodException etc. My first hint is to check the parameters of the method you are trying to invoke. No longer are the days of VB6 and variants where the "compiler" would go pretty far in trying to convert your types for you. If that still does not solve the issue, check out Ms. Cook's always informative posts. Also, the name (well, type) of and information in the exception that may acutally be a good hint at what is wrong.

 Reflect away...

Comments