Ralpharama
Ralpharama

Reputation: 461

Xamarin Live Player crashes when loading a bitmap, but it runs fine via USB connection

I've been following the examples for using SkiaSharp with Xamarin Forms, particularly the section on using bitmaps. I'm doing this in Microsoft Visual Studio 2017 version 15.9.11. I'm only targeting Android currently.

This page https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/basics/bitmaps has a section on Loading a Bitmap Resource, where the bitmap is an embedded image resource in the project.

So, we add the image and make it type 'embedded resource' added as an embedded resource

and then run the example code to simply display the image on the canvas.

string resourceID = "SkiaTest.Media.monkey.png";
Assembly assembly = GetType().GetTypeInfo().Assembly;

using (Stream stream = assembly.GetManifestResourceStream(resourceID))
{
    resourceBitmap = SKBitmap.Decode(stream);
}

All pretty simple, and it works fine if I run the code on my phone if it is connected via USB in the standard way (a Sony Z5) so the second in the list here, not the Player:

drop down list of players in VS

Here it is working via USB:

working via USB

But if I try and use Xamarin Live Player (the first in the list above) then it crashes on this line:

using (Stream stream = assembly.GetManifestResourceStream(resourceID))

enter image description here

Note that the app runs fine in Live Player if I don't try and load the bitmap, it's only that line that triggers the crash, and only in Live Player.

So I wonder if anyone has any ideas what could be causing Live Player to fail over this issue? Is the resource not being copied to the phone? Does Live Player just not support this type of activity?

Upvotes: 0

Views: 80

Answers (1)

FreakyAli
FreakyAli

Reputation: 16449

The reason you are facing this issue is that Embedded Resources are not yet supported by Xamarin Live player which is causing this exception.

More details can be found in the Troubleshooting Xamarin Live Player document.

Upvotes: 1

Related Questions