Assembly.GetManifestResourceStream always returns null

Viewed 7555

It is always confusing for me whenever I get to the tasks of Path-Resolution. I have the following information regarding the issue reported:

  • Using ASP.NET MVC-5 Application
  • Trying to access a font file i.e. MyriadPro-SemiBold.ttf via below code
//a value receives a path + name of the file in variable i.e. name
string name = "myApplicationName.fonts.MyriadPro-Semibold.ttf";

//object (named as assembly) of class System.Reflection.Assembly. 
var assembly = Assembly.GetExecutingAssembly();

using (Stream stream = assembly.GetManifestResourceStream(name))
// stream always gets null value (don't know why!)
{
    if(stream != null)
    {
        //myCode waiting for above stream not to be null :-(
    }
    else
    {
        throw new ArgumentException("No resource with name " + name);
    }
}

I don't know much about the way Visual Studio works in different types of Applications in the aspect of paths.

1 Answers
Related