When the ButtonTools in our application change Enabled status, meaning the images will change gray/color, then we get the following error. The BitmapImages are not set to IsFrozen by us so I think the ButtonTool is doing it.
[2010-08-12 08:57:52,078] [1] ERROR ALMobile.Client.App - An unhandled exception has occurred: System.InvalidOperationException: Specified value of type 'System.Windows.Media.Imaging.BitmapImage' must have IsFrozen set to false to modify. at System.Windows.Freezable.WritePreamble() at System.Windows.Freezable.remove_Changed(EventHandler value) at System.Windows.ResourceReferenceExpression.ResourceReferenceExpressionWeakContainer.RemoveChangedHandler() at System.Windows.ResourceReferenceExpression.ResourceReferenceExpressionWeakContainer.InvalidateTargetSubProperty(Object sender, EventArgs args) at System.Windows.Freezable.FireChanged() at System.Windows.Freezable.Freeze(Boolean isChecking) at System.Windows.PropertyMetadata.DefaultFreezeValueCallback(DependencyObject d, DependencyProperty dp, EntryIndex entryIndex, PropertyMetadata metadata, Boolean isChecking) at System.Windows.Freezable.FreezeCore(Boolean isChecking) at System.Windows.Media.Animation.Animatable.FreezeCore(Boolean isChecking) at System.Windows.Media.Imaging.BitmapSource.FreezeCore(Boolean isChecking) at System.Windows.Freezable.Freeze(Boolean isChecking) at System.Windows.Freezable.Freeze() at Infragistics.Windows.Controls.AutoDisabledImage.CoerceSource(DependencyObject d, Object newValue) at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks) 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.CoerceValue(DependencyProperty dp) at Infragistics.Windows.Controls.AutoDisabledImage.OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.PropertyChangedCallback.Invoke(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.CoerceValue(DependencyProperty dp) at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.UIElement.OnIsEnabledChanged(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.CoerceValue(DependencyProperty dp) at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.UIElement.OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at Infragistics.Windows.Ribbon.RibbonButtonChrome.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.CoerceValue(DependencyProperty dp) at System.Windows.UIElement.InvalidateForceInheritPropertyOnChildren(Visual v, DependencyProperty property) at System.Windows.UIElement.OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.PropertyChangedCallback.Invoke(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.CoerceValue(DependencyProperty dp) at System.Windows.Controls.Primitives.ButtonBase.set_CanExecute(Boolean value) at System.Windows.Controls.Primitives.ButtonBase.UpdateCanExecute() at System.Windows.Controls.Primitives.ButtonBase.OnCanExecuteChanged(Object sender, EventArgs e) at ALMobile.WeakEventHandler`1.Invoke(Object sender, EventArgs e) at ALMobile.UI.ALMobileRoutedCommand.<OnCanExecuteChanged>b__1() at ALMobile.SynchronizationContextExtensionMethods.<>c__DisplayClass1.<RunInSync>b__0(Object ignored) at ALMobile.SynchronizationContextExtensionMethods.RunInSync[T](SynchronizationContext that, Action`1 action, T state, Boolean synchronous) at ALMobile.SynchronizationContextExtensionMethods.RunInSync[T](SynchronizationContext that, Action`1 action, T state) at ALMobile.SynchronizationContextExtensionMethods.RunInSync(SynchronizationContext that, Action action) at ALMobile.UI.ALMobileRoutedCommand.OnCanExecuteChanged() at ALMobile.UI.ALMobileCommandBinding.ObjectToWatch_PropertyChanged(Object sender, PropertyChangedEventArgs e) at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e) at ALMobile.NotifyPropertyChangedBase.<>c__DisplayClass2.<OnPropertyChanged>b__0(String prop) at ALMobile.SynchronizationContextExtensionMethods.RunInSync[T](SynchronizationContext that, Action`1 action, T state, Boolean synchronous) at ALMobile.SynchronizationContextExtensionMethods.RunInSync[T](SynchronizationContext that, Action`1 action, T state) at ALMobile.NotifyPropertyChangedBase.OnPropertyChanged(String property) at ALMobile.Common.ViewModels.WorkspaceViewModelBase`4.set_ErrorText(String value) at ALMobile.Common.ViewModels.WorkspaceViewModelBase`4.OnCurrentItemDetailsViewModel_PropertyChanged(Object sender, PropertyChangedEventArgs e) at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e) at ALMobile.NotifyPropertyChangedBase.<>c__DisplayClass2.<OnPropertyChanged>b__0(String prop) at ALMobile.SynchronizationContextExtensionMethods.RunInSync[T](SynchronizationContext that, Action`1 action, T state, Boolean synchronous) at ALMobile.SynchronizationContextExtensionMethods.RunInSync[T](SynchronizationContext that, Action`1 action, T state) at ALMobile.NotifyPropertyChangedBase.OnPropertyChanged(String property) at ALMobile.Common.ViewModels.DetailViewModelBase.set_ErrorText(String value) at ALMobile.IErrorAwareExtensionMethods.HandleException(IErrorAware that, Exception x) at ALMobile.IErrorAwareExtensionMethods.TryOperation(IErrorAware that, Action operation) at ALMobile.Common.ViewModels.DetailViewModelBase.OnSave() at ALMobile.UI.ALMobileCommandBinding.<>c__DisplayClassa.<.ctor>b__7(Object s, ExecuteCommandEventArgs e) at ALMobile.UI.ALMobileCommandBinding.OnExecute(ExecuteCommandEventArgs args) at ALMobile.UI.ALMobileCommandManager.ExecuteCommand(ICommand command, Object parameter) at ALMobile.UI.ALMobileRoutedCommand.Execute(Object parameter) at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Some changes have been made in this element so you may want to re-test when the next SR is available which should be in a couple of weeks.
I am also experiencing this issue. In our case it is the AutoDisabledImage that is causing it but it only occasionally occurs and we still do not know how to reproduce it.
The exception eventually trickles out of Infragistics.Windows.Controls.AutoDisabledImage.CoerceSource(DependencyObject d, Object newValue)
Unfortunately, I cannot create a demo app because I cannot easily reproduce it.
We don't try to freeze the source image but we do freeze the converted bitmap we create to provide the grayed image. If you can provide a sample that demonstrates the issue we can look into it.
Is there any comment from Infragistics on this? I have recently been experiencing the same issue and agree with Will that the ButtonTool is Freezing the image resource perhaps in order to animate the image to make it look disabled. If the image resource is used in another ButtonTool either in the same window or a different window, this exception would occur when the other control attempts to freeze or animate the image.
Other than creating another image resource for the same image file, does Infragistics have any suggestions?
I have tried setting the resource x:Shared = "False" so that each use is a new instance, but I have had developers continue to report the issue.