-1
我得到参数计数不匹配异常。如何解决WindowsForms C#中的System.Reflection.TargetParameterCountException?
未处理的异常:System.Reflection.TargetParameterCountException:参数计数不匹配。
我对调用MethodInfo的基础代码部分如下
Type customerType = executingAssembly.GetType("LateBinding.Customer");
object customerInstance = Activator.CreateInstance(customerType);
MethodInfo method = customerType.GetMethod("printCustomerDetails");
string customerObject = (string)method.Invoke(customerInstance, new object[0]);
我试图调用下面的方法
public string printCustomerDetails(object parameters)
{
string CustomerName = "";
foreach (object customer in parameters)
{
CustomerName = CustomerName + " " + customer;
}
return CustomerName.Trim();
}
有什么我错过了调用MethodInfo的基地?
您应该检查printCustomerDetails方法的参数和相同数量的参数调用。 –
请显示对象声明。 – 2017-06-19 06:39:09
@TAHASULTANTEMURI我已经添加了代码。 – Arulpriya