Xamarin.UWP bug

0

There should be a bug in DotNetNativeToolChain. In project_name.UWP.csproj file, I have

<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>

In xaml, I have

<Image x:Name="testimage"></Image>

In code behind file, I have

testimage.Source = ImageSource.FromResource("project_name.testimage1.png");

testimage1.png is entered into project_name.csproj as

<EmbeddedResource Include="testimage1.png" />

Project can compile but crash with an error "Unhandled exception at 0x(Windows.UI.Xaml.dll) in .exe. 0xC000027B: An application-internal exception has occurred."

If I comment out the "UseDotNetNativeToolchain" in project_name.UWP.csproj file, the application runs smoothly.

xamarin.forms
xamarin.uwp
asked on Stack Overflow Nov 27, 2019 by Tek Mun

1 Answer

0
public ImageSource GetImageSource(string resource)
{
  ImageSource imagesource = null;
  Assembly assembly = GetType().GetTypeInfo().Assembly;
  MemoryStream ms = new MemoryStream();
  using (Stream stream = assembly.GetManifestResourceStream(resource))
  {
    if (stream != null)
    {
      stream.CopyTo(ms);
      imagesource = ImageSource.FromStream(() => new MemoryStream(ms.ToArray()));
    }
  }
  return imagesource;
}

In the code, I use

testimage.Source = GetImageSource("project_name.testimage1.png");
answered on Stack Overflow Nov 29, 2019 by Tek Mun

User contributions licensed under CC BY-SA 3.0