Friday, September 23, 2011

GetManifestResourceStream() returns NULL

If like me you're having problems accessing an embedded (assembly) resource using GetManifestResourceStream(), then read on:

GetManifestResourceStream was returning null even though I was pre-fixing the resource name with the namespace, i.e. NameSpace.Resource.ext.

The problem turned out to be the sub directory was missing from the name, in my example my resource lived under a folder (in the solution explorer) called Resources, so changing the qualified name to be:

NameSpace.Resources.Resource.ext fixed the issue.

Hope this helps someone else!

9 comments:

Ray said...

Thank-you!!

Anonymous said...

Thank you. That answered my query

Ghislain said...

thanks a lot I would say !

Anonymous said...

Brilliant....that has me stumped for about 5 seconds :)

Anonymous said...

Thanks!! This solved it for me

Anonymous said...

Thank you, that solved my problem!

Vincent Duvernet said...

From this article :
http://stackoverflow.com/questions/21637830/getmanifestresourcestream-returns-null

string[] array = this.GetType().Assembly.GetManifestResourceNames();
string[] array2 = Assembly.GetExecutingAssembly().GetManifestResourceNames();

Will help you to get resource name.

Anonymous said...

Ok, I had a weird situation. I had changed my namespace in code but not in the project properties. I was following these solutions and not getting anywhere until I went to my project properties and realized the Assembly name and Default Namespace needed to be changed to my new name!

local seo services said...

Kickstart your startup firm with our staggering digital marketing and SEO services.