0 votes

vb.net - image not displayed when running WPF

Hello, I have the following design:

<Window x:Class="MainWindow"
    Title="MainWindow" Height="350" Width="525">

<Grid Margin="0,0,0,0" Background="CadetBlue">
    <Border BorderBrush="DimGray " BorderThickness="2,2,2,2" Background="AliceBlue" Padding="5" CornerRadius="28" Margin="52,0,155,219" Height="52" VerticalAlignment="Bottom">
        <DockPanel HorizontalAlignment="Left" Height="46" LastChildFill="True" Margin="-2,-1,0,-7" VerticalAlignment="Top" Width="275">
            <Image x:Name="image" Height="46" VerticalAlignment="Top" Width="41" Source="pack://siteoforigin:,,,/Resources/user (1).png" />
            <TextBox BorderBrush="Transparent" x:Name="textBox" TextWrapping="Wrap" Text="TextBox" DockPanel.Dock="Right" Width="234" Height="40" VerticalAlignment="Top"/>

introducir la descripción de la imagen aquí

But I have problem when executing, because it ignores the image and only shows this: introducir la descripción de la imagen aquí

introducir la descripción de la imagen aquí

I add that when adding the image I did it as a resource. What is the problem? How can I solve it?


Carlos Adrián Points 263

The file "pack://siteoforigin:,,,/Resources/user (1).png" almost certainly does not exist. When you use siteoforigin instead of application, you have to copy the file to the path you indicate (with respect to the executable).

Check that the file exists, that it really is called user (1).png (with space in between), and try application instead of siteoforigin, since you say you have added it as a resource.

I think this information will come in handy: https://msdn.microsoft.com/en-us/library/aa970069.aspx#The_siteoforigin_____Authority


Lazaro Kelsy Points 197

Try setting this address only:


It has happened to me that when I press F5 the images do not load. However with Ctrl + F5 everything runs OK.


HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by: