Using Reflection (and O/R Mappers) with Nested Classes
I can't say that I've ever used a nested class myself, but I recently had a problem posted to my forums that involved a nested class and my ORMapper. I tested it myself and concluded that it was a bug due to my never having worrying about it before. Well it wasn't easy to find the solution, but I'm happy to report that there was no bug at all -- you just have to know the trick that .NET expects when using nested classes with reflection. It turns out that you should use a plus sign (+) instead of a dot (.) when referring to the nested class in a type name that you are going to reflect on -- so something like this: "Name.Space.Main+Nested". Its even in the MSDN docs here, although its not in other parts of the MSDN docs that I was originally looking for it at, like here. Anyhow, I assume this information will be useful to anyone using reflection with nested classes, and it probably applies to other O/R Mappers also, so it seemed worthy of posting on this blog.