そのため、Strings.resx リソースから生成されたプロパティのリストを取得しようとしています。そこからStringsクラスが自動生成され、単純にこれらのプロパティ名のリストを取得しようとしています。以下は、動作しないコードの例です。
// Well this works, so I know there is a property there.
var clearly_a_property = Strings.home_cancel;
// Yet none of this works
var nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.FlattenHierarchy);
nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.FlattenHierarchy);
nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Static);
nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.Public);
nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.FlattenHierarchy);
nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.Static);
nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.Instance);
nothing = typeof(Strings).GetProperties(System.Reflection.BindingFlags.DeclaredOnly);
nothing = typeof(Strings).GetProperties();
それで、何が得られますか?Stringsにアクセスしようとしているクラスは同じアセンブリ内にあるため、それは問題ではないと思います。
自動生成されたStringsクラスのスニペットを次に示します。
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Strings {
//------------------
// other stuff ...
//------------------
internal static string home_cancel {
get {
return ResourceManager.GetString("home_cancel", resourceCulture);
}
}
//------------------
// other stuff ...
//------------------
}