I have a DynamicObject-based class that implements an interface dynamically (via TryGet* and TryInvoke*). I want to call the methods that it implements using reflection. The problem is that it throws a TargetException (Object does not match target type).
Like I said, it's dynamic, so it forwards the calls via a series of connections as text to another program, which then calls the destination method using reflection. It is basically a proxy class. The method names are known at compile time (because of the interface), but are called externally.
typeof(ITelescope).GetMethod(Console.ReadLine()).Invoke(prox,null);
ITelescope is the interface, prox
is the dynamic object.