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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.