Search code examples
c#windows-phone

Windows phone filepicker


I have a problem with FilePicker in Windows Phone 8.1

I'm set up a FilePicker object like that:

                FileOpenPicker filePicker = new FileOpenPicker();
                filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                filePicker.ViewMode = PickerViewMode.List;
                filePicker.FileTypeFilter.Add(".xml");
                filePicker.FileTypeFilter.Add(".txt");
                filePicker.PickSingleFileAndContinue();

                view.Activated += View_Activated;

Before that I'm setting up a view object:

view = CoreApplication.GetCurrentView();

File Picker is invoked properly, I'm selecting a file, after that I got unhandled exception in App class.

"Error in line 1 position 229. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data of the 'http://schemas.datacontract.org/2004/07/SQLite:Task' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Task' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer."

View_Activated method is never invoked.

What can be wrong?


Solution

  • You shouldn't be using the activated for the page. The activation process should start in the App.xaml.cs

    Check this link for SilverLight: https://msdn.microsoft.com/en-us/library/windows/apps/dn642086(v=vs.105).aspx

    Check this link for normal: https://www.jayway.com/2014/04/16/windows-phone-8-1-for-developers-contracts/