为什么我不能忽略使用PowerShell的调用的返回值?

时间:2014-03-03 22:32:58

标签: powershell

当我在Powershell中从外部类型调用它时:

Add-Type -Path "$sdk_path\bin\DataProvider.dll"
$queryProcessor = New-Object -Type QuestionAnswering.QueryProcessor($linguisticDB, $index)
$queryProcessor.Process(query)

我可以看到函数调用返回一个int。我收到以下错误消息:

The result type 'System.Int32' of the dynamic binding produced by the object with type 
'System.Management.Automation.PSObject' for the binder 'PSInvokeMember: Process ver:0 
args:1 constraints:<args: >' 
is not compatible with the result type 'System.Object' expected by the call site.

我不需要任何东西的int值,但我似乎无法指示Powershell忽略它。例如,这些仍然返回相同的错误:

[void]$queryProcessor.Process(query)
$queryProcessor.Process(query) | Out-Null

我还能尝试什么?

1 个答案:

答案 0 :(得分:8)

您正在使用PowerShell中的错误。

请尝试以下解决方法:

$queryProcessor.Process.Invoke(query)