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

Exception with ImageSource.FromFile("") on Android

$
0
0

Hi, With Xamarin Froms on Android following exception is throwing when I set image source with ImageSource.FromFile("filename.png"). Image build action is set to 'AndroidResource'. Do any one have idea what is wrong here?

var img= new Image
{
Source = ImageSource.FromFile("filename.png"),
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
};

UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.Android.ResourceManager.GetId (System.Type type, System.String propertyName) [0x00000] in :0
at Xamarin.Forms.Platform.Android.ResourceManager.IdFromTitle (System.String title, System.Type type) [0x00000] in :0
at Xamarin.Forms.Platform.Android.ResourceManager.GetBitmap (Android.Content.Res.Resources resource, System.String name) [0x00000] in :0
at Xamarin.Forms.Platform.Android.FileImageSourceHandler+d__0.MoveNext () [0x00000] in :0


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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