1
我有一個PCL定位ASP.NET核心& .NET Framework 4.6。如何從PCL訪問嵌入式資源定位ASP.NET CORE和.NET Framework 4.6
在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"));
結果null
使用dotPeek,我可以看到PCLResrouce.txt的DLL。
如何作爲用戶訪問Embedded Resource文本文件?
我用以下資源:
- 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?
我意識到我拼寫錯誤的資源:/而不是多數民衆贊成這個問題。