serilog-sinks-richtextbox
serilog-sinks-richtextbox copied to clipboard
Logging a 01h causes parent app to crash
I have a process that parses XML files. One of those files is corrupt. In my try..catch block, I Log.Warning the ex.message.
That message is:
"Name cannot begin with the '" & ChrW(1) & "' character, hexadecimal value 0x01. Line 1084, position 71."
Note that this is the debugger message, so the CharW(1) is actually a 01h character.
This causes the whole parent app to crash, with these messages (and I have substituted the string [01h] for the actual character):
XamlParseException: '[01h]', hexadecimal value 0x01, is an invalid character. Line 1, position 468.
Error parsing `<Paragraph xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve"><Run Foreground="#808080">[</Run><Run Foreground="#c0c0c0">14:24:41</Run><Run Foreground="#808080"> </Run><Run Foreground="#ffff00">WRN</Run><Run Foreground="#808080">] </Run><Run Foreground="#00ffff">_[My File Name]_</Run><Run Foreground="#ffffff">: </Run><Run Foreground="#00ffff">Name cannot begin with the '[01h]' character, hexadecimal value 0x01. Line 1084, position 71.</Run>
</Paragraph>` to XAML: '[01h]', hexadecimal value 0x01, is an invalid character. Line 1, position 468.
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in WindowsBase.dll
Exception has been thrown by the target of an invocation.