This question is locked. New answers and comments are not allowed.
The following code doesn't drop into the catch block on an error in the xml. If I have a string "Test" in my content, the code errors on the italic line below with this error. And will not drop in to the catch block.
{System.Windows.Markup.XamlParseException: illegal xml character [Line: 1 Position: 2]
at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers, Boolean expandTemplatesDuringParse)
at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)
at System.Windows.Markup.XamlReader.Load(String xaml)
at Telerik.Windows.Documents.FormatProviders.Xaml.XamlFormatProvider.Import(String input)
at Telerik.Windows.Documents.FormatProviders.Xaml.XamlFormatProvider.Import(Stream input)
at ICollegeLifeSLClient.Classes.RadDocSupport.ImportXaml(String content)}
{System.Windows.Markup.XamlParseException: illegal xml character [Line: 1 Position: 2]
at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers, Boolean expandTemplatesDuringParse)
at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)
at System.Windows.Markup.XamlReader.Load(String xaml)
at Telerik.Windows.Documents.FormatProviders.Xaml.XamlFormatProvider.Import(String input)
at Telerik.Windows.Documents.FormatProviders.Xaml.XamlFormatProvider.Import(Stream input)
at ICollegeLifeSLClient.Classes.RadDocSupport.ImportXaml(String content)}
public RadDocument ImportXaml(string content)
{
try
{
IDocumentFormatProvider provider = new XamlFormatProvider();
RadDocument document;
using (MemoryStream stream = new MemoryStream())
{
StreamWriter writer = new StreamWriter(stream);
writer.Write(content);
writer.Flush();
stream.Seek(0, SeekOrigin.Begin);
document = provider.Import(stream);
}
return document;
}
catch (Exception ex)
{
string message = ex.Message;
return null;
}
}