2014-03-03 2 views
5

나는이 PowerShell에서 외부 유형에서 호출 할 때 : 나는 함수 호출 int를 반환하는 것을 볼 수 있습니다PowerShell을 사용하여 호출의 반환 값을 무시할 수없는 이유는 무엇입니까?

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

. 나는 다음과 같은 오류 메시지가 얻을 :

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 

그 밖의 어떤 조치를 취할 수 있습니까?

답변

8

PowerShell에서 버그가 발생했습니다.

는 해결 방법으로 다음과 같은 시도 :

$queryProcessor.Process.Invoke(query) 
+0

완벽한, 그 작품! 비록 차이점을 이해할 수있는 척하지 않습니다 : -/ – GuruJ

+0

나는 이것을 해결 방법으로 생각할 수도있는 소수의 사람들 만 생각할 수 있습니다. 따라서 그것을 이해하는 것에 대해 걱정할 필요가 없습니다. –

+4

그리고 설명하기 위해 - $ queryProcessor.Process는 PSMethod를 반환합니다. PSMethod.Invoke (...)를 구현하는 코드 경로에는 버그가 없습니다. –

관련 문제