I’d like to use Reflection in combination with dynamic.
Lets say i have the following call
dynamic foo = External_COM_Api_Call()
Accessing an object that i receive using COM.
Now I’d like to do somthing like that:
String bar = foo.GetType().GetProperty("FooBar").GetValue(foo,null)
But i keep getting a null for the PropertyInfo.
Ideas?
Why using reflection when you could directly:
That’s the whole point of the
dynamickeyword. You no longer need reflection.And if you want to use reflection then don’t use dynamic:
Here’s a full working example: