Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

WinPhone: Exception on StreamImagesourceHandler LoadImageAsync

$
0
0

In one of my Dependency Services on WinPhone I'm trying to convert a StreamImageSource to an image using the StreamImagesourceHandler.
I'm stuck as it results in an exception.
When I run the following code:

IImageSourceHandler imgSourceHandler = new StreamImagesourceHandler();
var img = await imgSourceHandler.LoadImageAsync(source);

This will result in the following exception:
Read is not supported on the main thread when buffering is disabled.
Stacktrace:
at MS.Internal.InternalNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Http.HttpClientHandler.WebExceptionWrapperStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Http.DelegatingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Windows.Media.Imaging.BitmapSource.SetSourceInternal(Stream streamSource)
   at System.Windows.Media.Imaging.BitmapImage.SetSourceInternal(Stream streamSource)
   at Xamarin.Forms.Platform.WinPhone.StreamImagesourceHandler.<LoadImageAsync>d__0.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
1.GetResult()
at ***.WinPhone.DependencyServices.Picture_WinPhone.d__2.MoveNext()`

I'm I doing something wrong or is this a bug?
I'm not having that much experience with WinPhone. This same method is working fine on iOS and Android.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>