FileOpenPicker: Can't add complex type to ContinuationData

1

I am not able to add a custom type to he ContinuationData in the FileOpenPicker. I can add string/int/datetime, but when I try to add my custom CustomFolder object it fails with the following exception.

CustomFolder TargetFolde = new CustomFolder()
FileOpenPicker open = new FileOpenPicker();
open.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
open.ViewMode = PickerViewMode.Thumbnail;

// Filter to include a sample subset of file types
open.FileTypeFilter.Clear();
open.FileTypeFilter.Add(".bmp");
open.FileTypeFilter.Add(".png");
open.FileTypeFilter.Add(".jpeg");
open.FileTypeFilter.Add(".jpg");

KeyValuePair<string, object> fold = new KeyValuePair<string, object>("Folder", TargetFolder);
open.ContinuationData.Add(fold);
open.PickMultipleFilesAndContinue();
}

{System.Exception: Data of this type is not supported. (Exception from HRESULT: 0x8007065E) at System.Runtime.InteropServices.WindowsRuntime.IMap2.Insert(K key, V value) at System.Runtime.InteropServices.WindowsRuntime.MapToDictionaryAdapter.Insert[K,V](IMap2 _this, K key, V value) at System.Runtime.InteropServices.WindowsRuntime.MapToDictionaryAdapter.Add[K,V](K key, V value) at System.Runtime.InteropServices.WindowsRuntime.MapToCollectionAdapter.Add[K,V](KeyValuePair`2 item) at Lockie.Shared.Util.d__1b.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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Lockie.Folder.d__5.MoveNext()}

c#
windows-phone-8
asked on Stack Overflow Dec 3, 2014 by Eric Langland • edited Dec 3, 2014 by DJ Burb

1 Answer

1

Only basic types are allowed. WinRT does not offer a serialization mechanism like .NET

You can serialize the data yourself using XML or JSON and store that as a string.

answered on Stack Overflow Dec 4, 2014 by Peter Torr - MSFT

User contributions licensed under CC BY-SA 3.0