I have a program written in C# WPF to print documents automatically. One of the features it has is it can detect image download failure so the document which has that empty image doesn't get printed.
This is one part of the code to detect download failure of 'sender logo' image:
_senderLogoFrame = BitmapFrame.Create(new Uri(_invoice.Sender.Logo));
_senderLogoFrame.DownloadFailed += BitmapFrameDownloadFailed;
SenderLogo.Source = _senderLogoFrame;
When the event handler BitmapFrameDownloadFailed from _senderLogoFrame.DownloadFailed is invoked, this exception is occurred:
shippingLabelForm.CreateDocument Exception: Specified value of type 'System.Windows.Media.Imaging.BitmapFrameDecode' must have IsFrozen set to false to modify. Stack Trace: at System.Windows.Freezable.WritePreamble() at System.Windows.Media.Imaging.BitmapSource.add_DownloadFailed(EventHandler`1 value) at InvoicePrintingClient.Form.ShippingLabelForm.SetDataToElements() at InvoicePrintingClient.Form.ShippingLabelForm.d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at InvoicePrintingClient.Main.PrintClientMainWindow.<>c__DisplayClass101_1.<b__4>d.MoveNext()
What does it mean by setting IsFrozen to false? Does it have anything to do with the BitmapSource.DownloadFailure event handler? What do I have to do to resolve this problem?