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?
The xml was improperly formatted.
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: The xml was improperly formatted.
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").
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").
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: The xml was improperly formatted.
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.
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.
See the attachment.
Thanks
Thanks
- Attachments
-
- 1.png (57.54 KiB) Viewed 2642 times
Re: The xml was improperly formatted.
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.
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.
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.
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
}
- Attachments
-
- Test-XMLIssue.psf
- (17.49 KiB) Downloaded 94 times
Re: The xml was improperly formatted.
The backspace doesn't produce a printable character. We will look into this and see what we can do.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: The xml was improperly formatted.
Ok thanks for confirming that it's just a simple bug I can ignore.
Re: The xml was improperly formatted.
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.