title: Loading a resource from within a class library in .NET Core
body: <p>I have a class library that has a method that is called from a parent project. I want the class library to load an embedded resource when a method is called.</p>
  
  <p>Example: The console app has a class library called TestClass. This has an embedded resource called test.txt. When I call a method on TestClass, I want to read the resource test.txt.</p>
  
  <pre><code>Console App
    |  TestClass.dll
         |  test.txt
  </code></pre>
  
  <p>I have tried this code:</p>
  
  <pre><code>var assembly = Assembly.GetEntryAssembly();
  var stream = assembly.GetManifestResourceStream("TestClass.test.txt");
  </code></pre>
  
  <p>But this looks in the console app, not the class library.</p>
  
  <p>I looked at this example: <a href="http://keithelder.net/2007/12/14/how-to-load-an-embedded-resource-from-a-dll" rel="nofollow noreferrer">http://keithelder.net/2007/12/14/how-to-load-an-embedded-resource-from-a-dll</a><a href="http://keithelder.net/2007/12/14/how-to-load-an-embedded-resource-from-a-dll" rel="nofollow noreferrer">enter link description here</a>, but this is loading the file from the parent app, not from within the class library itself.</p>