Xamarin.UWP: Image from embedded resource throws “Operation is not supported on this platform” error

If you are getting the error “Operation is not supported on this platform” when you are trying to set an ImageResource from file for an image on Xamarin.UWP, then the problem comes from this line of code:

IconSource = ImageSource.FromResource("afolder.animage.jpg");

The solution: Image as Embadded Ressource shows “operation is not supported on this platform” in UWP and Release (microsoft.com)
In a short brief: You need to use the second parameter for FromResource method call. You must pass an assembly in order to success on UWP platform. iOS and Android is not affected with this error.

IconSource = ImageSource.FromResource("afolder.animage.jpg", typeof(AClassFromTheAssembly).Assembly);
This content has 2 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.