I'm making a Windows Phone 8.1 app (Windows Runtime, not Silverlight 8.1), and I need to create a WriteableBitmap from a Stream, but when I try to do so, I get this exception: "An exception of type 'System.Exception' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: The component cannot be found. (Exception from HRESULT: 0x88982F50)"
I have tried a lot of things, but still no luck. My code is as follows:
private async void Button_Click(object sender, RoutedEventArgs e)
{
var files = await KnownFolders.CameraRoll.GetFilesAsync();
for(int i=0; i<files.Count; i++)
{
var fileStream = await files[i].OpenReadAsync();
if(fileStream != null)
{
WriteableBitmap writeableBmp = await BitmapFactory.New(1, 1).FromStream(fileStream);
}
}
}
But this doesn't happen if I replace
var fileStream = await files[i].OpenReadAsync();
with, for example,
var fileStream = await files[0].OpenReadAsync();
Any ideas? Thank you.