Reputation: 6291
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 :
And
Stream stream = assembly.GetManifestResourceStream(string.Format("PCL.PCLResrouce.txt"));
results in null
Using dotPeek, I can see PCLResrouce.txt in the DLL.
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.
Upvotes: 2
Views: 641
Reputation: 6291
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.
Upvotes: 1