The xml was improperly formatted.

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
aartogba
Posts: 15
Last visit: Tue Jan 23, 2024 8:00 am

The xml was improperly formatted.

Post 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?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: The xml was improperly formatted.

Post by jvierra »

Where are you using XML in your code?

Can you post the exact error text or an image of the error message?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: The xml was improperly formatted.

Post 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").
David
SAPIEN Technologies, Inc.
User avatar
aartogba
Posts: 15
Last visit: Tue Jan 23, 2024 8:00 am

Re: The xml was improperly formatted.

Post 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.
User avatar
aartogba
Posts: 15
Last visit: Tue Jan 23, 2024 8:00 am

Re: The xml was improperly formatted.

Post by aartogba »

See the attachment.

Thanks
Attachments
1.png
1.png (57.54 KiB) Viewed 2593 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: The xml was improperly formatted.

Post 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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: The xml was improperly formatted.

Post 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.
Attachments
Test-XMLIssue.psf
(17.49 KiB) Downloaded 93 times
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: The xml was improperly formatted.

Post by davidc »

The backspace doesn't produce a printable character. We will look into this and see what we can do.
David
SAPIEN Technologies, Inc.
User avatar
aartogba
Posts: 15
Last visit: Tue Jan 23, 2024 8:00 am

Re: The xml was improperly formatted.

Post by aartogba »

Ok thanks for confirming that it's just a simple bug I can ignore.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: The xml was improperly formatted.

Post 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.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked