2

I have a PCL Targeting ASP.NET CORE & .NET Framework 4.6.

In the root of PCL, I have added PCLResource.txt and marked it as Build Action > Embedded Resource.

Publish to NuGet, Installed from NuGet to my Consumer WinForm App (4.6.2)

Calling PCL.TestMethod() works. However,

string[] asm = Assembly.GetExecutingAssembly().GetManifestResourceNames();

And

var assembly = GetType().GetTypeInfo().Assembly;
string[] resources = assembly.GetManifestResourceNames();

results in :

  • PCLConsumerApp.Form1.resources
  • PCLConsumerApp.Properties.Resources.resources

And

Stream stream = assembly.GetManifestResourceStream(string.Format("PCL.PCLResrouce.txt"));

results in null

Using dotPeek, I can see PCLResrouce.txt in the DLL. dotPeek of PCL Resources

How do I get access to the Embedded Resource text file as a consumer?

I have used the following resources:

And I realize I mispelled resource :/ but thats not the issue.

Community
  • 1
  • 1
ttugates
  • 5,818
  • 3
  • 44
  • 54

1 Answers1

1

My issue was I was not getting the PCL Assembly.

Solution:

var assembly = Assembly.GetAssembly(typeof(StaticPCLClass));

I am not necessarily working with this class when I need the resource, but this allows me to get the Assembly. Now I am able to call:

Stream stream = assembly.GetManifestResourceStream(string.Format("PCL.PCLResrouce.txt"));

Used help from here.

Community
  • 1
  • 1
ttugates
  • 5,818
  • 3
  • 44
  • 54