Friday 14 October 2011

Reflection - the perils

I've been struggling with Reflection. I want to create an object from a dynamically loaded assembly. In general, this is a simple problem. Just use Type.InvokeMember, easy!

However, the problem comes when the constructor does other stuff, particularly when it loads yet more objects by reflection from dynamically loaded libraries. When it doesn't work, it can be really difficult to diagnose.

The upshot of this is that it would be so much better if the constuctor did the minimum amount and all the initialisation came later, once the object had been created etc.

Just a thought.

No comments:

Post a Comment