0

I'm trying to load my company logo as an embedded image into the program, but I'm getting a null stream when I try to save it to my logo variable. I've looked up examples, and my code seems to be right, but it doesn't work. Is there a way I can check what all my values should be for the string in the second line? Thanks!

        var stream = typeof(Program).Assembly.GetManifestResourceStream("[Point Of Sales.vshost.exe].[POS_System.csproj].Images.logo.bmp");
        logo = Image.FromStream(stream);
Nathan
  • 1,287
  • 6
  • 15
  • 32
  • Perhaps you have the same issue as discussed here: http://stackoverflow.com/questions/10726857/why-does-getmanifestresourcestream-returns-null-while-the-resource-name-exists-w –  Oct 29 '13 at 23:44
  • As an aside the process with `vshost.exe` in its name is not your program but the visual studio hosting process. – codemonkeh Oct 30 '13 at 00:57
  • you're trying to get the image from the application resources: http://stackoverflow.com/questions/1192054/load-image-from-resources-area-of-project-in-c-sharp – spajce Oct 30 '13 at 02:10

1 Answers1

1

You need to specify the namespace of the project the resource is located in, not the file name.

For example if your namespace is MyProject.MyCode, then your import statement should be something like:

var stream = typeof(Program).Assembly.GetManifestResourceStream("MyProject.MyCode.Images.logo.bmp");
logo = Image.FromStream(stream);

For more information: http://support.microsoft.com/kb/319292

codemonkeh
  • 2,054
  • 1
  • 20
  • 36