I have created an instance called input
that is of type:
public class TestInput
{
public int TesTInt { get; set; }
}
I use this in this function:
public static class TestClass
{
public static string TestFunction()
{
var testInput = new TestInput();
string res = ServicesManager.Execute<string>((object) testInput);
return res;
}
}
The Execute
function is here:
public static OUT Execute<OUT>(object input)
where OUT : class
{
var method = //getting method by reflection
object[] arr = new object[] { input };
return method.Invoke(null, arr) as OUT; //Error is triggered here
}
The method that I invoke is this one:
public static string TestFunctionProxy(object[] input)
{
var serviceInput = input[0] as TestInput;
//rest of code
}
I received the error in the title. (XXX - "TestInput" type)
What's happening and what is causing this error?
Note: method
is static so no instance is required for the first parameter. Please correct me if I'm wrong.
Any help is appreciated.
EDIT: Updated the question with some more code for a complete example.