日期:2014-05-17  浏览次数:21457 次

BeginInvoke 参数计数不匹配 谁给帮帮忙?
private void DllInvoke(string DllFileName, string NameSpace, string ClassName, string MethodName, object[] ObjArrayParams)
  {
  try
  {
  Assembly DllAssembly = Assembly.LoadFrom(DllFileName);
  Type[] DllTypes = DllAssembly.GetTypes();
  foreach (Type DllType in DllTypes)
  {
  if (DllType.Namespace == NameSpace && DllType.Name == ClassName)
  {
  MethodInfo MyMethod = DllType.GetMethod(MethodName);
  if (MyMethod != null)
  {
  object mObject = Activator.CreateInstance(DllType);
  //MyMethod.Invoke(mObject, new object[] { ObjArrayParams });
  LogicalMethodInfo myLogicalMethodInfo = (LogicalMethodInfo.Create(new MethodInfo[] { MyMethod }))[0];

  IAsyncResult myAsyncResult = myLogicalMethodInfo.BeginInvoke(mObject, new object[] { ObjArrayParams }, null, null);
  }
  }
  }
  }
这个方法调用时为什么一直提示参数类型不匹配?

------解决方案--------------------
object[] ObjArrayParams 中的参数的顺序,是否与名字为"MethodName"的参数类型、顺序一致。