Hey friends, today we will take a quick look at a little, but annoying problem we still face in Xamarin Forms. I guess you might have come across this error message “[0:] ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri:“.

This error is quite simple to identify. Here is how it manifests itself. You want to display an image in your app from an external source on the internet, you bind the URL to an image view, or pass it directly, but once you run your app the image doesn’t appear. In my experience, this error occurs when you try to display an image in Xamarin Forms from a source that does not have an SSL-certified URL. This error might be caused by some other complex things that I don’t yet know, but in my case, it occurred when I passed URLs with the “HTTP:” instead of “HTTPS:”.

So, in this short post, I share with you how you can overcome the error described above very easily. To overcome it, we will create a value converter that downloads the image for us. Once we have the image, we use a memory stream to pass the image to the image view via the converter. And that is all. So, here is the code.

The value converter to resolve ImageLoaderSourceHandler: Could Not Retrieve Image or…

Now, applying this converter is very easy. To learn more about value converters, check these docs. This is how we do it.

Conclusion

That is all. You can just copy and paste this value converter whenever you come across this issue. As simple as that. Hey, if you like my articles and videos, please don’t forget to like and subscribe to my channel and blog for more tips and tricks for software dev, especially dotnet dev. You might also like this post about this super powerful media player for Xamarin Forms.

Follow me on social media and stay updated

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.