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:
Thank-you!!
Thank you. That answered my query
thanks a lot I would say !
Brilliant....that has me stumped for about 5 seconds :)
Thanks!! This solved it for me
Thank you, that solved my problem!
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.
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!
Kickstart your startup firm with our staggering digital marketing and SEO services.
Post a Comment