Page 1 of 2

The xml was improperly formatted.

Posted: Fri Sep 28, 2018 5:35 am
by aartogba
Hi everyone,

I have a Windows form with a textbox in it. When I use debugger on KeyPress Event after pressing backspace key and look for the $_.KeyChar property, it shows me "The XML was improperly formatted. Please escape if it necessary". What's going on here?

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 6:00 am
by jvierra
Where are you using XML in your code?

Can you post the exact error text or an image of the error message?

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 6:46 am
by davidc
Is this message appearing when you hover over the variable?

What value do you see in the Variables panel (or the Watch panel if you right-click on the property and use "Add to Watch").

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 7:14 am
by aartogba
I don't use any XML in this script.

The message appears when I hover the mouse over the $_ variable. There is no value in the watch panel when I type $_.KeyChar.

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 7:22 am
by aartogba
See the attachment.

Thanks

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 7:50 am
by jvierra
Thanks for the image. I will let David respond as this is likely an issue with PSS or, possibly, your PSF file is corrupted which can cause all manner of odd behaviors. David and Sapien would be able to ascertain this.

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 8:05 am
by jvierra
I just copied your code and can reproduce the issue. I believe it can be ignored as it it just trying to show the tooltip text for $_.KeyChar which apparently cannot be decoded. This only happens if we hit the BackSpace key.

Here is the simplest form that reproduces the issue.

Code: Select all

$form1_Load={
}
$textbox1_KeyPress=[System.Windows.Forms.KeyPressEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.KeyPressEventArgs]
       Write-Host $_.KeyChar
}
Attached is a simple form with one textbox that shows your issue. I suspect the wrong internal message is being extracted or possible the tooltip generator has a simple bug. I think we can safely ignore this for now.

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 8:09 am
by davidc
The backspace doesn't produce a printable character. We will look into this and see what we can do.

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 8:12 am
by aartogba
Ok thanks for confirming that it's just a simple bug I can ignore.

Re: The xml was improperly formatted.

Posted: Fri Sep 28, 2018 8:15 am
by jvierra
davidc wrote: Fri Sep 28, 2018 8:09 am The backspace doesn't produce a printable character. We will look into this and see what we can do.
That would explain the XML error as most unprintable characters haved to be escaped in XML so the fix should be trivial except for the regression testing.

It is clearly not anything that affects the script or the debugging other than a vague and uninformative message.