0
我有一個類庫,它有一個從父項目調用的方法。我希望類庫在調用方法時加載嵌入的資源。從.NET類庫中加載類庫中的資源
示例:控制檯應用程序具有名爲TestClass的類庫。這有一個名爲test.txt的嵌入式資源。當我在TestClass上調用方法時,我想讀取資源test.txt。
Console App
| TestClass.dll
| test.txt
我曾嘗試這樣的代碼:
var assembly = Assembly.GetEntryAssembly();
var stream = assembly.GetManifestResourceStream("TestClass.test.txt");
但這看起來在控制檯應用程序,而不是類庫。
我看了這個例子:http://keithelder.net/2007/12/14/how-to-load-an-embedded-resource-from-a-dllenter link description here,但是這是從父應用程序加載文件,而不是從類庫本身。