【发布时间】:2017-08-31 14:22:21
【问题描述】:
我有一个面向 ASP.NET CORE 和 .NET Framework 4.6 的 PCL。
在 PCL 的根目录中,我添加了 PCLResource.txt 并将其标记为 Build Action > Embedded Resource。
发布到 NuGet,从 NuGet 安装到我的消费者 WinForm 应用程序 (4.6.2)
调用PCL.TestMethod() 有效。然而,
string[] asm = Assembly.GetExecutingAssembly().GetManifestResourceNames();
和
var assembly = GetType().GetTypeInfo().Assembly;
string[] resources = assembly.GetManifestResourceNames();
结果:
- PCLConsumerApp.Form1.resources
- PCLConsumerApp.Properties.Resources.resources
和
Stream stream = assembly.GetManifestResourceStream(string.Format("PCL.PCLResrouce.txt"));
结果为@987654330@
使用 dotPeek,我可以在 DLL 中看到 PCLResrouce.txt。
我如何以消费者身份访问嵌入式资源文本文件?
我使用了以下资源:
- Tip: Accessing Binary Resources in Portable Class Library
- How to read a text file on Xamarin Forms PCL project?
- How to read a resource file within a Portable Class Library?
我意识到我拼错了资源:/但这不是问题。
【问题讨论】:
标签: dll asp.net-core embedded-resource portable-class-library .net-4.6