Nathan
Nathan

Reputation: 1347

Null stream when loading embedded image

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);

Upvotes: 0

Views: 244

Answers (1)

codemonkeh
codemonkeh

Reputation: 2152

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

Upvotes: 1

Related Questions