Resource could not be found when adding image as asset
See original GitHub issueI’m trying to add an image to my project as an asset. I am following the MVVM template and the Assets guide on the Quickstart page. I have my image in a folder called Assets in my project directory and have included assets in my project file.
The image is present in the folder: Assets\image.png which is in my project directory
In my .csproj file I have:
<AvaloniaResource Include="Assets\*" />
In my view I have:
<Image Source=:image.png" />
The error I am getting is: Could not convert object ‘imapge.png’ (of type System.String) to {clr-namespace:Avalonia.Media.Imaging;assembly=Avalonia.Visuals}IBitmap: The resource image.bmp could not be found.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Flutter web asset images not displaying when deployed to ...
In my case, the problem was I was using Image.network instead of Image.asset which did not cause an error when running locally as...
Read more >Adding assets and images | Flutter
Adding assets and images ... Flutter apps can include both code and assets (sometimes called resources). An asset is a file that is...
Read more >[Solved] Unable to load asset Error in Flutter
This error occurs when you have incorrectly indexed the image or image folder in pubspec.yaml file. Error Message: ══╡ EXCEPTION CAUGHT BY IMAGE...
Read more >2 Easy Steps to Fix Unable to Load Asset in Flutter
Step 1: Make sure you have added the correct image path (without a spelling mistake). Note: To always get the correct image path...
Read more >Load images and assets tailored for scale, theme, high ...
Your app can load image resource files containing images tailored for display scale factor, theme, high contrast, and other runtime ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it should be
<Image Source="/Assets/image.png" />
https://github.com/AvaloniaUI/Avalonia/blob/c637d616ba26584e9add2cd09d58788be7833b06/samples/ControlCatalog/Pages/ImagePage.xaml#L21After I changed the Build Action to Embedded Resource this worked. Thanks.