public override void Perform() { Stream stream = SerializeToStream(); if (stream == null) { return; } XamlReader xamlReader = new XamlReader(); xamlReader.LoadCompleted += new AsyncCompletedEventHandler(LoadCompleted); try { xamlReader.LoadAsync(stream); } catch (XamlParseException xpe) { bool isIgnorableMessage = xpe.Message.Contains("No matching constructor"); //Fix isIgnorableMessage = isIgnorableMessage | xpe.Message.Contains("CancelPrint"); //Work around isIgnorableMessage = isIgnorableMessage | xpe.Message.Contains("invalid character"); // Ignoring XamlParseException with specific message, as Xaml cannot load types with no default constructor if (!isIgnorableMessage) { // Context is lost for the current exception because of the catch // Calling the method again so that debugger breaks at the throwing location stream.Seek(0, SeekOrigin.Begin); XamlReader.Load(stream); } } if (IsCanceled) { xamlReader.CancelAsync(); } }