程序集和ResourceName无效
本文关键字:无效 ResourceName 程序集 | 更新日期: 2023-09-27 18:21:55
我有这个代码:
Assembly myAssembly = Assembly.GetExecutingAssembly();
foreach (string resourceName in myAssembly.GetManifestResourceNames())
{
ManifestResourceInfo info = myAssembly.GetManifestResourceInfo(resourceName);
}
为什么信息总是为空?我有7个ResourceFiles(.resx),其中一个的resourceName看起来是这样的:
"SchemaDifferenceFinder.Model.SQLStatements.MissingTriggers.resources"
出了什么问题,或者resourceName一定是其他名称吗?
尝试
System.Reflection.Assembly assem = System.Reflection.Assembly.Load("TestLibrary");
System.Resources.ResourceManager rman = new System.Resources.ResourceManager("TestLibrary.Properties.Resources", assem);
String s = rman.GetString("String1");
你需要创建资源管理器,然后访问资源的数据
编辑
var assembly = Assembly.GetExecutingAssembly();
foreach (var resourceName in assembly.GetManifestResourceNames())
System.Console.WriteLine(resourceName);