Pythonnet List <字符串>无法转换类型

问题描述

我正在将.dll与python一起使用,以便将命令发送到运动控制器。大多数请求都可以,但是尝试以下操作时我遇到了困难:

from System.Collections.Generic import List
from System import String

result,response_list,err_string = SMC.ZT(1,List[String],"")

# The Error:
result,list_parameters,err_string = self.SMC.ZT(ctlr_address,err_string)
System.ArgumentException: Unable to convert type object 'System.RuntimeType' in type 'System.Collections.Generic.List`1[System.String]&'.
   to System.RuntimeType.TryChangeType(Object value,Binder binder,CultureInfo culture,Boolean needsspecialCast)
   to System.Reflection.MethodBase.CheckArguments(Object[] parameters,BindingFlags invokeAttr,Signature sig)
   to System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj,Object[] parameters,CultureInfo culture)
   to System.Reflection.RuntimeMethodInfo.Invoke(Object obj,CultureInfo culture)
   to Python.Runtime.MethodBinder.Invoke(IntPtr inst,IntPtr args,IntPtr kw,MethodBase info,MethodInfo[] methodinfo)

# Syntax from the docs:
# int ZT(int controllerAddress,out List<string> Parameters,out string errstring)
# controllerAddress: controllerAddress
# Parameters: Parameters
# errString: The failure reason
# return: 0 in success and -1 on failure

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)