Is it possible in .NET, to invoke a method/function on an object and get back it's return value without knowing the type of the object?
All the examples I could find so far use reflection and need to know the type of the object to get it's method list to invoke them.
In short, I want to invoke a method of a given name and with given parameters on any object, and get back the return value, in case this method really exists.
For example: Let's say I have a library X.dll with a class Y and a function Z inside it. Function Z takes two string parameters and returns a string.
I have another library A.dll, which is NOT referencing X.dll. A.dll has a function B somewhere inside it, which takes an object of type Y as a parameter, but since there's no referencing, this parameter is declared as object
. Inside this function B I need to invoke function Z and do something with it's return value.