Yesterday I did a bit of working using DynamicMethod. I have to admit, that was the first time I touched that class. I like diving into the Emit namespace, but I haven't had the need to crank out a shim method like that. Anyway, as I was reading the documentation, I found this:

If the dynamic method is associated with a type, it has access to the private members of the type.

Just what does that mean, exactly? It smelled like something that I've seen in JavaScript:

What this shows to me is that you can add new methods to specific object instances (you can also do this in JavaScript - I just didn't show that in my code example). However, you can't attach a method to a class such that it's a part of every class instance (for some reason I think a Smalltalker is telling me, "if only a class was an object..."). You can attach a method to a type - in this case, it acts like a static method. In either case, both methods have access to the internals of the object. I tried using InvokeMethod() to see if I could "find" the new method, and that doesn't seem to work (although my code could be wrong too).

Dynamic methods are another cool aspect of .NET. Just do a search on "DynamicMethod" and you'll find all sorts of cool little nuggests out there. If your code has the right permissions, you're never limited by your language; you can always get around limitations by visiting the Emit namespace.