PowerShell运行方法与类型参数

时间:2014-08-09 00:52:05

标签: c# powershell types casting

在尝试端口时需要一些帮助,以下代码从C#到PowerShell。总的来说,它只是来自客户.dll的一种方法,我们在传递参数之前定义一个类型。这在C#中运行良好,但似乎无法在PowerShell中实现。请注意,在PowerShell中加载.dll没有问题,我可以访问它的所有方法。只是无法成功运行它。

在C#中,我按如下方式运行方法:

tool.FindById<Type>("Name","Id")

在PowerShell中,我尝试过以下操作但没有成功:

tool.FindById("Name","Id") = This errors out with Cannot find an overload for FindById and the argument count...

[Type]tool.FindById("Name","Id") = This errors out with the same error as the first one.

tool.FindById([Type]("Name","Id")) = This errors out with Cannot convert the "System.Object[]" value of Type "System.Object[]" to Type "Type"...

关于如何解决这个问题的任何信息都会很棒!

0 个答案:

没有答案