2

I have a module called xModule. I have an image inside it marked as embedded resource.

Inside the initialization of the module I tried :

string stFileName = "SmallIcon.png";
string stAssembly = "xModule"; // That's the full name of the assembly
//img.BeginInit();

Uri uri = new Uri(String.Format(@"/{0};component/Images/{1}", stAssembly , stFileName),
                  UriKind.Relative);
ImageSource imgSource = new BitmapImage(uri);

During it's coming to the breakpoint on the ImageSource imgSource =.. line, it seems the ImageSource can't find the image...

Why? What's wrong with it?

I get no errors, the assembly is referenced. I did something similar in the Xaml and it worked. Also used : VS11, Unity

LastBye
  • 1,143
  • 4
  • 19
  • 37

1 Answers1

1

I think you need to mark the image as "ressource" not "embedded ressource" ( WPF )

also See : What's the difference between a Resource and an Embedded Resource in a C# application?

Community
  • 1
  • 1
Mohnkuchenzentrale
  • 5,745
  • 4
  • 30
  • 41
  • 1
    Thanks giving the info, but anyway no difference in the result. I tried that also in addition with build:Content. No difference. Packed URI's give "Cannot locate resource 'images/smallicon.png'" this error and the URI I used above during a watch shows a similar result. As I said earlier this way I don't get any errors. – LastBye Nov 08 '12 at 13:51