Copying object with ImageSource type of properties throws exception
See original GitHub issueHi. I use this library for creating a snapshot of my view model in WPF app. Currently I have few properties that are of type ImageSource. They are bound to the view via INotifyPropertyChanged interface. I noticed that when creating deep copy of my view model, by grouping all the properties in dictionary <string, object>, where string is property name, and object is the value of the property,
I get the following inner exception: BitmapMetadata initialization incomplete. | System.Exception {System.InvalidOperationException
Stack trace of inner exception: at System.Windows.Media.Imaging.BitmapMetadata.EnsureBitmapMetadata() at System.Windows.Media.Imaging.BitmapMetadata.SetQuery(String query, Object value) at System.Windows.Media.Imaging.BitmapMetadata.set_Rating(Int32 value)
Complete stack trace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at System.Reflection.PropertyInfo.SetValue(Object obj, Object value)
at FastDeepCloner.FastDeepClonerProperty.SetValue(Object o, Object value)
at FastDeepCloner.ReferenceClone.ReferenceTypeClone(Dictionary2 properties, Type primaryType, Object objectToBeCloned, Object appendToValue) at FastDeepCloner.ReferenceClone.Clone(Object objectToBeCloned) at FastDeepCloner.ReferenceClone.ReferenceTypeClone(Dictionary
2 properties, Type primaryType, Object objectToBeCloned, Object appendToValue)
at FastDeepCloner.ReferenceClone.Clone(Object objectToBeCloned)
at FastDeepCloner.ReferenceClone.Clone(Object objectToBeCloned)
at FastDeepCloner.DeepCloner.Clone[T](T objectToBeCloned, FieldType fieldType)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
There is now a fix for this, have a look here https://github.com/AlenToma/FastDeepCloner/blob/master/Documentations/NoneCloneableAttribute.md
You need to add
NoneClonable
to yourImageSource1
, as i guss there will be the error