Вопрос

When I call this from an external type in Powershell:

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

I can see that the function call returns an int. I get the following error message:

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.

I don't need the int value for anything, but I can't seem to instruct Powershell to ignore it. For example, these still return the same error:

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

What else can I try?

Это было полезно?

Решение

You are hitting a bug in PowerShell.

Try the following as a workaround:

$queryProcessor.Process.Invoke(query)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top