-1

我已经在 Powershell 2.0 中的 Win XP 和 Windows Server 2008 R2 上对此进行了测试:

$a = 1,2,3,4 # a simple [object[]] but any other Type is good

如果我做:

$a.addres()

返回错误是(正确):

Method invocation failed because [System.Object[]] doesn't contain a method named 'addres'.

但如果我这样做:

$a.address()

错误是:

Cannot find an overload for "Address" and the argument count: "0".

但是做:

$a.address(2)

关闭 powershell 控制台'Problem Event Name: APPCRASH'

从那开始[system.array]还没有一个方法叫addresspowershell怎么尝试调用一个已有的方法呢?

4

2 回答 2

3

[System.Array] 具有 .Get、.Set 和 .Address 方法,这些方法可通过 .Net 运行时使用,但通常不在 Powershell 代码中使用。看看这篇 StackOverflow文章

于 2012-04-06T15:20:01.777 回答
1

我不久前将其作为错误提交。他们用 Keith 发布的异常消息在 V3 中修复了它(可能会破坏运行时的稳定性)

https://connect.microsoft.com/PowerShell/feedback/details/561865/powershell-crashes-when-calling-address-method-on-object-array

于 2012-04-06T17:11:29.167 回答