I have a lot of images I want to use in an application I'm working on. However, the more I add as a resource, the slower Visual Studio gets. I assume this is because it's due to recompiling with all of the resources in the same project. So I was hoping to add them to a separate class library and use them from there. It works in the designer, however the image does not appear during run time.
The image is in a class library named Icons, with a subfolder of Icons, and in this case a smiley.png file. The smiley.png Build Action has been set to Resource within the Icons project.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="Icons\smiley.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\smiley.png" />
</ItemGroup>
</Project>
The main project is a WPF Application (.NET Core 3.1) called Test. In the MainWindow.xaml I just have the starter grid and an image.
<Grid>
<Image Source="/Icons;component/Icons/smiley.png" Width="450" />
</Grid>
Test is also referencing icons.
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Icons\Icons.csproj" />
</ItemGroup>
</Project>
To be clear I want to use the icons as a resource from a class library. Not as content copied to the build directory. I have also attached images just in case I wasn't clear on something. I have also tried with both relative and absolute URIs, the result is the same.
I've tried everything I can think of at this point. It works if the image is in the main project as a resource, but not when it's in a referenced assembly. Though according to the docs this should work. I'm stumped as to why it isn't.