2

Hi Iam loading image at runtime.I have the problem where i have to place the image in folder.Actually i put it in folder named as Image.But it shows the error that it can not find image in folder ...bin\debug\HH.bmp.

So i pasted it in debug folder and works fine. But when i take EXE out of Debug folder and when i run it,it does not work. Why? Then how can i add image in such case?

Is there any way to add image in resource file, Like in MFC..

src1 = @"HH.bmp";
Img1.Source = new ImageSourceConverter().ConvertFromString(src1 ) as ImageSource;
Anu
  • 905
  • 4
  • 23
  • 54
  • It show me the error Could not find a part of the path 'C:\WpfApp;component\data\HH.png'. – Anu Mar 04 '10 at 04:21

3 Answers3

0

This is very similar to another question. Check out WPF image resources

EDIT

<Image Source="../Images/icon.png" />
Community
  • 1
  • 1
Steve Danner
  • 21,818
  • 7
  • 41
  • 51
  • I used like "src1 = @"pack://application:,,,/WpfApp;component/data/HH.bmp";Its works fine.But when i convert it to Control Library,it didnot works.It shows error.that cannot load assembly – Anu Mar 04 '10 at 04:49
  • Can you set the image property in the XAML instead? The way we do it here is to set it like I have in the edit of my answer... – Steve Danner Mar 04 '10 at 13:42
0

If you run this application will search the image in the current Assembly directory. just try like this <Image source="/yournamespace;component/Images/Close.png"> there should be an image folder with close.png in the solution. No need of the image or image folder in the debug folder.

Kishore Kumar
  • 21,449
  • 13
  • 81
  • 113
  • It show me the error Could not find a part of the path 'C:\WpfApp;component\data\HH.png'. And im doing this in C# coding not in XAML – Anu Mar 04 '10 at 04:22
  • 1
    k just try this ImgControl.Source=new BitmapImage(new URI(@"/yournamespace;component/Images/Close.png",UriKind.Relative)); – Kishore Kumar Mar 04 '10 at 06:47
0

Set the [assembly: NeutralResourcesLanguage("en")] to "en" culture in AssemblyInfo.cs file. Check your assembly resource culture!

[assembly: AssemblyCulture("")]
[assembly: AssemblyConfiguration("")]
[assembly: ComVisible(false)]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en")]