Set Icon broken in latest SR candidate?

Our plug-in stopped working in the latest SR26 candidate because setting the Icon property of a dialog now throws the error below. This issue is new as of the latest SR candidates (that is, it does not occur in SR25). I should mention that we are building against SR18, but the same error occurs when building against SR25. Will we have to move up our references for SR26? This is of course doable, but highly undesirable, as most institutional users (large firms, universities, etc.) do not update Rhino frequently.

System.ObjectDisposedException: Cannot access a disposed object.
   at System.Windows.Media.Imaging.BitmapSource.CriticalCopyPixels(Int32Rect sourceRect, IntPtr buffer, Int32 bufferSize, Int32 stride)
   at System.Windows.Media.Imaging.BitmapSource.CriticalCopyPixels(Int32Rect sourceRect, Array pixels, Int32 stride, Int32 offset)
   at System.Windows.Media.Imaging.BitmapSource.CopyPixels(Int32Rect sourceRect, Array pixels, Int32 stride, Int32 offset)
   at System.Windows.Media.Imaging.BitmapSource.CopyPixels(Array pixels, Int32 stride, Int32 offset)
   at MS.Internal.AppModel.IconHelper.CreateIconHandleFromBitmapFrame(BitmapFrame sourceBitmapFrame)
   at MS.Internal.AppModel.IconHelper.CreateIconHandleFromImageSource(ImageSource image, Size size)
   at MS.Internal.AppModel.IconHelper.GetIconHandlesFromImageSource(ImageSource image, IconHandle& largeIconHandle, IconHandle& smallIconHandle)
   at System.Windows.Window.UpdateIcon()
   at System.Windows.Window._OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.Window.set_Icon(ImageSource value)
   at Eto.Wpf.Forms.WpfWindow`3.set_Icon(Icon value) in D:\BuildAgent\work\commercial\src4\DotNetSDK\Eto\src\Eto.Wpf\Forms\WpfWindow.cs:line 378

Thanks,

Jon

Hi @sarg,

Can you provide a simple, sample project that repeats the error?

Thanks,

– Dale

Hi @dale,

Sure. Simple project here. The command tries to open a dialog with an icon, but fails. Must be built against SR25 or earlier (package included) for the exception to arise.

Thanks,

Jon

Hi @sarg,

The attached shows another approach to loading an icon. In this projects, CS.ico is an embedded resource.

TestIcon.zip (33.6 KB)

– Dale

Thanks, @dale.

The FromResource() constructor solves the issue. We will make the switch.

Unfortunately, as it stands the Rhino update will still break previously functioning installations of our plug-in. Is it possible to fix the file-stream constructor on your end, so this doesn’t happen? And if not, can there be a clear communication issued when breaking changes like this are planned? It was a bit of a fluke that I even discovered it.

Much appreciated,

Jon

@curtisw, can you confirm or deny anything has changed in Eto that would cause this?

Yes, something was changed that broke this unintentionally. I’ll get this fixed up with RH-58972.

:+1: Thanks @curtisw!