Xamarin.UWP Release Embedded Image error,but debug no problem. Code short and very easy.
MainPage.xaml code below
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="EmbImg.MainPage"
xmlns:local="clr-namespace:EmbImg">
<StackLayout>
<Image Source="{local:EmbeddedImg ResourceId=EmbImg.Picture.pic.ico}"
VerticalOptions="CenterAndExpand" HorizontalOptions="Center"/>
</StackLayout>
</ContentPage>
EmbeddedImg.cs code below
internal class EmbeddedImg : IMarkupExtension
{
public string ResourceId { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
return ImageSource.FromResource(ResourceId);
}
}
error message: System.PlatformNotSupportedException Message=Operation is not supported on this platform.
Sir: give me any idea to slove this error.
return ImageSource.FromResource(ResourceId);
fix code
return ImageSource.FromResource(ResourceId,typeof(EmbeddedImg).assembly);