While doing some testing of a HTML to XAML converter I'm working on, I ran across a strange situation that I can't explain. Due to a bug in my HTML to XAML converter I was given this XAML:
<Section xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
When I set the XAML property of the RichTextBox to this string it ignores my try/catch and crashes the entire app with this error:
System.AccessViolationException was unhandled Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
My code is simple:
try {
rtb.Xaml = ptb.Text;
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
Why is this exception not caught? I tried adding an AccessViolationException catch, but that didn't change anything. Thank you for your time.
(Note: this is Silverlight 4)