I created one dll Library to put image resources files in .
and I use"/{namespace;component/Resources/{filesname}}"in xaml to get this file.
this works good in net framework,but seems not well in .net core and .net5
what should I do now.
I created one dll Library to put image resources files in .
and I use"/{namespace;component/Resources/{filesname}}"in xaml to get this file.
this works good in net framework,but seems not well in .net core and .net5
what should I do now.
I use /{namespace;component/Resources/{filesname}} in xaml to show in .Net5 Wpf application with below steps:
Dll part:
Create a WPF .NET Application named MyDll, its target platform is .NET 5
Add a file named Resources and include a image 969.jpg in it.
Choose Resource for Build Action and Copy always for Copy to Output Directory .
Make it to dll refer to steps in : How to Convert a WPF Windows Application to dll
WPF Project part:
Create a WPF .NET Application named EmbededResourcesImage, its target platform is .NET 5.
Add MyDll.dll to its Dependencies.
Use the image like <Image Source="/MyDll;component/Resources/969.jpg"></Image> in xaml
Build Action Instructions (Refer to doc)
Resource (WPF only): Embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources.
Embedded resource: Embeds the file in an exclusive assembly manifest resource.
If I misunderstand your question, please point out.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
But when I choose Resource for Build Action,this Resources file or image file would be removed from project...what's wrong with this? thank u please
@ShawnSong-3285
What does your Resources file or image file would be removed from project mean? Could you give me more explaination about it?

this file would be removed like this,and reports "can't find the resource" error when it running
I had exactly the same problem and those files are automatically removed when changed to "Resource". In my case I changed the project from raw Class library to UserControl Class library:
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Version>1.0.9</Version>
</PropertyGroup>
Done. Images are not removed any more
6 people are following this question.