我有这个代码:
Assembly myAssembly = Assembly.GetExecutingAssembly();
foreach (string resourceName in myAssembly.GetManifestResourceNames())
{
ManifestResourceInfo info = myAssembly.GetManifestResourceInfo(resourceName);
}
为什么信息始终 null ?我有7个ResourceFiles(.resx),其中一个的 resourceName 看起来像这样:
"SchemaDifferenceFinder.Model.SQLStatements.MissingTriggers.resources"
什么是错的,或者resourceName必须是其他东西吗?
答案 0 :(得分:0)
尝试
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);