すべて、C#アプリケーションをローカライズしていて、設定を制御できるようになりました。私が使用しているのでPropertyGrid
、オプションを提供するためにプロパティを使用しています。CategoryAttribute
さまざまな言語で表示する必要がある「サーバーアクセス」用のものがあります-私は持っていました:
[CategoryAttribute("ServerAccess"),
ReadOnlyAttribute(false),
XmlElement,
DescriptionAttribute("Message about the Server Access Option.")]
public bool ShowSystemDatabases
{
get { return this.showSystemDatabases; }
set { this.showSystemDatabases = value; }
}
そして私はこれを次のように変更しようとしました:
[CategoryAttribute(ObjectStrings.SettingsServerAccess),
ReadOnlyAttribute(false),
XmlElement,
DescriptionAttribute(MessageStrings.SettingsShowSystemDatabaseInfo)]
public bool ShowSystemDatabases
{
get { return this.showSystemDatabases; }
set { this.showSystemDatabases = value; }
}
私のリソースファイルはどこObjectStrings
にありますか('ObjectStrings.resx' et al。)。これはコンパイル時エラーをスローしています
An attribute argument must be a constant expression, typeof expression or array
creation expression of an attribute parameter type...
コンストラクターが。を期待している場合は、明らかに文字列を使用できませんconst string
。string
いろいろな家の周りの方法を使ってからキャストしようとしましconst string
たが、すべて失敗しました。それは十分に単純な問題ですが...
この問題を回避する最も簡単な方法は何ですか?
御時間ありがとうございます。