dotnet / dotnet/android

Images are not displayed in release with AndroidEnableMarshalMethods=true

Open
#9,810 4 comments 0 reactions 0 assignees View on GitHub
Area: Marshal Methods possibly-stale
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

### Description

I am not understanding what caused such behavior: marshaling or together with trimming or AOT. But Images are not displayed in release on android with AndroidEnableMarshalMethods is true.

`true`
```
public class ImgResExtension : IMarkupExtension
{
public string? Source { get; set; }
public object? ProvideValue(IServiceProvider serviceProvider)
{
if (Source == null)
return null;
var path = $"Maui9MarshalAndImageBug.Resources.Images.{Source}";
//return ImageSource.FromResource(path);
var assembly = Assembly.GetAssembly(typeof(App));
if (assembly is null)
return null;
var stream = assembly.GetManifestResourceStream(path);
if (stream is null)
return null;
return ImageSource.FromStream(() => stream);
}
}
```
```

```

### Steps to Reproduce

see the repository

### Link to public reproduction project repository

git@github.com:alex3696/Maui9MarshalAndImageBug.git
https://github.com/alex3696/Maui9MarshalAndImageBug.git

### Version with bug

9.0.40 - no image
9.0.30 - app crash

### Is this a regression from previous behavior?

Not sure, did not test other versions

### Last version that worked well

_No response_

### Affected platforms

Android

### Affected platform versions

tested on Andriod9 device and virtual Andriod14

### Did you find any workaround?

_No response_

### Relevant log output

```shell

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.