Search code examples
c#wpfresources.net-assembly

Image in XAML from another assembly is not loaded (does not appear)


I don't understand, an image from the same assembly is shown as expected. An image from another assembly (referenced) seems to not be loaded (does not appear).

Partial code:

        <Button Command="Play" ToolTip="Execute Macro">
            <Image Source="pack://application:,,,/ParametricStudySharedGui;component/Image/arrowRight32x32.png" Height="24" Width="24"/>
        </Button>

I did try to add next line in App.OnStartup without success:

    Assembly.Load("ParametricStudySharedGui");

That happen in my application MainWindow on an image defined as "Resource" (like the one from the same assembly which work fine).

Please also take note that the image is shown as expected in Visual Studio design window.

I also tried to modified resource path without success as:

<Image Source="/ParametricStudySharedGui;component/Image/arrowRight32x32.png" Height="24" Width="24"/>

Any idea ???


Solution

  • Please also take note that the image is shown as expected in Visual Studio design window.

    In that case, I suspect Visual Studio simply didn't rebuild the assembly containing the image. I find this happens from time to time: if you add or overwrite an image or other resource, but you make no code changes, the new/updated image may not get included in the build.

    Try doing a full Clean and Rebuild of your solution.