0

I have two projects This is the main WPF project configuration where I want to display the image from a referenced project. The main project is a .NET Core WPF with the name CH07.RemoteBinaryResourceDemo.csproj and the referenced project .NET Framework Class Library CH07.ResourceLibrary.csproj Can anyone please help

This is my CH07.RemoteBinaryResourceDemo.csproj

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net7.0-windows</TargetFramework>
        <Nullable>enable</Nullable>
        <UseWPF>true</UseWPF>
    </PropertyGroup>

    <ItemGroup>
      <ProjectReference Include="..\CH07.ResourceLibrary\CH07.ResourceLibrary.csproj" />
    </ItemGroup>

</Project>

I have another project the referenced project .NET Framework Class Library, with the file structure

+CH07.ResourceLibrary
+--+Images
   +--+image1.jpg

In my CH07.RemoteBinaryResourceDemo/MainWindow.xaml

<Image Width="150"
               Margin="8"
               Source="pack://application:,,,/CH07.ResourceLibrary;component/Images/image1.jpg"/>

This doesn't work. I've tried everything I know to build, clean build, rebuild doesn't work.

ASh
  • 34,632
  • 9
  • 60
  • 82
  • The Build Action of the image file must be Resource. The library should be a WPF class library. – Clemens Aug 16 '23 at 05:12
  • I did that and it still didn't display, I even tried content – Ifiok Ekott Aug 16 '23 at 06:23
  • Is `CH07.ResourceLibrary` the correct assembly name? The library project `CH07.ResourceLibrary.csproj` should generate an assemby named `CH07.ResourceLibrary.dll`. Is it a WPF library? – Clemens Aug 16 '23 at 06:33
  • Yes that the correct assembly name and yes it's a WPF library – Ifiok Ekott Aug 16 '23 at 16:10
  • The only suggestion I can make is that you compile CH07.ResourceLibrary, remove your project reference and add a reference to the compiled assembly. As Clemens says, ensure that you have set the Build Action to Resource for your images. Leave the Copy to Output Directory blank as with all the other properties for the image. If you willing to post your project I would be happy to review it – Dragan Radovac Aug 17 '23 at 00:33

0 Answers0