Problem serialising relative uri BitmapImages

Apr 15, 2011 at 3:22 PM

Has anyone else had issues trying to Save tables that have BitmapImage columns but only if the images have a relaive uri? I can save them no problem if the uri is Absolute, but if I, for example, try and save a camera image or locally stored image with a relative uri I get an exception from the database instance Save method that 'This operation is not supported on a relative URI.'

The stack trace is :

at System.Uri.get_AbsoluteUri()
at Wintellect.Sterling.Serialization.ExtendedSerializer.<.ctor>b__4(BinaryWriter bw, Object obj)
at Wintellect.Sterling.Serialization.ExtendedSerializer.Serialize(Object target, BinaryWriter writer)
at Wintellect.Sterling.Serialization.AggregateSerializer.Serialize(Object target, BinaryWriter writer)
at Wintellect.Sterling.Serialization.SerializationHelper._SerializeProperty(Type type, Object propertyValue, BinaryWriter bw)
at Wintellect.Sterling.Serialization.SerializationHelper._InnerSave(Type type, Object instance, BinaryWriter bw, CycleCache cache)
at Wintellect.Sterling.Serialization.SerializationHelper.Save(Type type, Object instance, BinaryWriter bw, CycleCache cache)
at Wintellect.Sterling.Serialization.SerializationHelper._InnerSave(Type type, Object instance, BinaryWriter bw, CycleCache cache)
at Wintellect.Sterling.Serialization.SerializationHelper.Save(Type type, Object instance, BinaryWriter bw, CycleCache cache)
at Wintellect.Sterling.Database.BaseDatabaseInstance.Save(Type type, Object instance, CycleCache cache)
at Wintellect.Sterling.Database.BaseDatabaseInstance.Save(Type type, Object instance)
at Wintellect.Sterling.Database.BaseDatabaseInstance.Save[T](Item instance)
at AllMyStuff.ViewModel.DetailViewModel.SaveChanges()
at AllMyStuff.DetailPage.saveButton_Click(Object sender, EventArgs e)
at Microsoft.Phone.Shell.ApplicationBarItemContainer.FireEventHandler(EventHandler handler, Object sender, EventArgs args)
at Microsoft.Phone.Shell.ApplicationBarIconButton.ClickEvent()
at Microsoft.Phone.Shell.ApplicationBarIconButtonContainer.ClickEvent()
at Microsoft.Phone.Shell.ApplicationBar.OnCommand(UInt32 idCommand)
at Microsoft.Phone.Shell.Interop.NativeCallbackInteropWrapper.OnCommand(UInt32 idCommand)

Any ideas?

 

 

 

 

 

 

Coordinator
Apr 15, 2011 at 3:30 PM

Sterling has native support for WriteableBitmap. Have you tried letting the bitmap resolve, then copying it to a Writeable Bitmap and using that for persistence? You can see the example in the unit tests.

Apr 15, 2011 at 3:53 PM
Thanks for the quick response! I'll give it a try and let you know how I got on. Love the framework btw!

Sent from my Windows Phone
Apr 16, 2011 at 12:30 AM

That worked a treat, thanks for that.