Thread: tee-object bug
View Single Post
Old 12-19-2007   #3 (permalink)
Steven Hystad
Guest


 
 

Re: tee-object bug

At first glance it would appear to me that Tee-Object is trying to copy the
XmlDocument by creating a new XmlNode. However, that would be impossible as
XmlNode is abstract. It would be more rational to try to create a new
XmlDocument.

After throwing the exception into my errordialog script I see that it is
actually trying to dynamically invoke a method.
A fast search in .NET Reflector found a static "XmlNode" method.

Microsoft.PowerShell.ToStringCodeMethods.XmlNode(PSObject) as String
within System.Management.Automation.dll

There were no other overloads visible.

Looking at the stack trace I see it being called by
PSObject.ToString(String, IFormatProvider).

$a.ToString($null, $null) will give the same error.

It seems to be that PSObject.ToString(String, IFormatProvider) can not
process correctly when it is overridden by the XmlNode code method.

PSObject.ToString is being called by the Set-Variable cmdlet so I don't see
any easy way around this bug.

"Karl Prosser[MVP]" <karl@xxxxxx_o_w_e_r_s_h_e_l_l.com> wrote in message
news:%23BmlLChQIHA.4584@xxxxxx
Quote:

> [xml]$a = "<hello>there</hello>"
> $a | tee-object -variable test
>
> gives
>
> Exception retrieving string: "Cannot find an overload for "XmlNode" and
> the argument count: "3"."
>
> .. anybody dare to suggest the cause of this bug. Maybe a side effect of
> the powershell adapter. and an assumption tee-object makes?
>
> -Karl
My System SpecsSystem Spec