You cannot call a method on a null-valued expression.

Sep 28, 2010 at 7:36 AM

I collect W2003 32-bit  IIS server performance and now try to analyze it whti this new PAL v2.0.3 and after some time when the script is running I have this kind of error.

I´m using W7x64 Enteprise workstation for this.

.....

        Quantizing "shstat#1" for Avg, Min, Max, and Trend values...Done
        Counter data for "shstat"...Done
        Quantizing "shstat" for Avg, Min, Max, and Trend values...Done
        Counter data for "System"...Done
        Quantizing "System" for Avg, Min, Max, and Trend values...Done
        Counter data for "_Total"...Done
        Quantizing "_Total" for Avg, Min, Max, and Trend values...Done
WARNING: Please post errors or problems with this tool to the PAL web site
located at http://www.codeplex.com/PAL with the following error message and a
brief description of what you were trying to do. Thank you.
You cannot call a method on a null-valued expression.
At C:\Program Files\PAL\PAL v2.0.3\PAL.ps1:2102 char:55
+         If ($iUBound -gt $aSortedNumbers.GetUpperBound <<<< (0))
    + CategoryInfo          : InvalidOperation: (GetUpperBound:String) [], Par
   entContainsErrorRecordException
    + FullyQualifiedErrorId : InvokeMethodOnNull


C:\Program Files\PAL\PAL v2.0.3>

Thanks for the help in advance :)

Coordinator
Sep 29, 2010 at 9:25 AM

Many non-English users are receiving this error. We know that it is related to use of a non-English-US locale. Please try switching to an English-US locale to see if that works. If you are able, please debug this and offer updates to the PowerShell code.

Sep 29, 2010 at 11:17 AM

Hello! I've struggled a little with the same problem but thanks to the Clint's suggestion I've made some progress...

I just couldn't believe the tool can't parse it's own sample data. ;-) Tried on XP(Polish) and Svr2003(English) and even tried an earlier 'PAL2.0beta' version but had had the same problem. Changing "regional settings" (which was Polish even on English WinSvr2003) helped and revealed some roots of the problem.

The main problem seems to be that numbers (and peraps times) are in the US standard but Powershell tries to parse them with current locale (as it probably should). I've modified two functions in PAL.ps1 (see below) and the tool doesn't break now. Still the report produced by such modified version has some differences in alerts over the same sample data so there must be more places that need mending...

I can send my reports - one made on Svr2003 with changed locale and the other on XP with PAL.ps1 modifications - if it would be helpful...

Wojtek


1) IsNumeric (tryparse changed to invariant parsing with trapped exception)
--- BEFORE ---
Function IsNumeric
{
    param($Value)
    [double]$number = 0
    $result = [double]::TryParse($Value, [REF]$number)
    $result
}
--- AFTER ---
Function IsNumeric
{
    param($Value)
    trap [Exception]
    {
        return $false
    }
    [void][double]::parse($Value, [Globalization.CultureInfo]::InvariantCulture)
    return $true
}

2) MakeNumeric (casts changed to invariant parsing, two lines changed)
--- BEFORE ---
Function MakeNumeric
{
    param($Values)
    #// Make an array all numeric
    $alNewArray = New-Object System.Collections.ArrayList
    If (($Values -is [System.Collections.ArrayList]) -or ($Values -is [Array]))
    {
        For ($i=0;$i -lt $Values.Count;$i++)
        {
            If ($(IsNumeric -Value $Values[$i]) -eq $True)
            {
                [Void] $alNewArray.Add([System.Double]$Values[$i])
            }
        }
    }
    Else
    {
        [Void] $alNewArray.Add([System.Double]$Values)
    }
    $alNewArray
}

--- AFTER ---
Function MakeNumeric
{
    param($Values)
    #// Make an array all numeric
    $alNewArray = New-Object System.Collections.ArrayList
    If (($Values -is [System.Collections.ArrayList]) -or ($Values -is [Array]))
    {
        For ($i=0;$i -lt $Values.Count;$i++)
        {
            If ($(IsNumeric -Value $Values[$i]) -eq $True)
            {
                [Void] $alNewArray.Add([double]::parse($Values[$i], [Globalization.CultureInfo]::InvariantCulture))
            }
        }
    }
    Else
    {
        [Void] $alNewArray.Add([double]::parse($Values, [Globalization.CultureInfo]::InvariantCulture))
    }
    $alNewArray
}