次のような列挙型のローカライズされた値にアクセスしているときに、エラーを下回っています
@(((FeeType)Model[i].FeeType).GetDescription())
Could not find any resources appropriate for the specified culture or the neutral culture.
Make sure "Resources.Admin.resources" was correctly embedded or linked into assembly "Auction" at compile time, or that all the satellite assemblies required are loadable and fully signed.
私の列挙型は
public enum FeeType
{
[LocalizedDescriptionAttributre("Site_Fee_Type_MonthlyServiceFee", typeof(Resources.Admin))]
ClientFees = 1
}
拡張クラスは
public class LocalizedDescriptionAttributre : DescriptionAttribute
{
private readonly string _resourceKey;
private readonly ResourceManager _resource;
public LocalizedDescriptionAttributre(string resourceKey, Type resourceType)
{
_resource = new ResourceManager(resourceType);
_resourceKey = resourceKey;
}
public override string Description
{
get
{
string displayName = _resource.GetString(_resourceKey);
return string.IsNullOrEmpty(displayName)
? string.Format("[[{0}]]", _resourceKey)
: displayName;
}
}
}
public static class EnumExtensions
{
public static string GetDescription(this Enum enumValue)
{
FieldInfo fi = enumValue.GetType().GetField(enumValue.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute),
false);
if (attributes != null &&
attributes.Length > 0)
return attributes[0].Description;
else
return enumValue.ToString();
}
}