Bug 39685 - ImageSource.FromResource doesn't work on UWP in release
Summary: ImageSource.FromResource doesn't work on UWP in release
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.1.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-03-16 16:05 UTC by michael@zpf.fr
Modified: 2017-03-23 16:39 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Sample solution (846.58 KB, application/x-zip-compressed)
2016-03-16 16:05 UTC, michael@zpf.fr

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description michael@zpf.fr 2016-03-16 16:05:45 UTC
Created attachment 15431 [details]
Sample solution

For convenience I'm storing some of my images in the shared PCL library.  The access to them via ImageSource.FromResource is working fine in all checked platforms but UWP.

It’s working fine in “debug” but in “release”, even if we can list the resource, ImageSource.FromResource won’t load it:

         string log = "";

         var assembly = typeof(HomePage).GetTypeInfo().Assembly;
         foreach (var res in assembly.GetManifestResourceNames())
            log +=  string.Format( "found resource: {0} - {1} \n",  res,  (ImageSource.FromResource(res) != null).ToString());

Comment 1 Jason Smith [MSFT] 2016-03-16 17:15:02 UTC
Are you trying the api where you do:

var src = ImageSource.FromResource ("name", typeof (HomePage));

In .NET Native you need to tell .FromReosurce what assembly (or type within assembly) the resource can be found in because we cant easily enumerate all assemblies.

Reopen if this doesn't fix your problem.
Comment 2 Tom Soderling 2016-10-07 17:17:53 UTC
Why isn't this in the documentation anywhere?!?  This is a direct contradiction to what is stated in the docs: https://developer.xamarin.com/guides/xamarin-forms/working-with/images/#Images_embedded_in_other_projects_dont_appear

"Image.FromResource only looks for images in the same assembly as the code calling FromResource."
Comment 3 Paul DiPietro [MSFT] 2017-03-23 14:01:09 UTC
*** Bug 53854 has been marked as a duplicate of this bug. ***