LoginSignup
3
0

More than 3 years have passed since last update.

【C#】アクセシビリティーに一貫性がありません でちょっと詰まった話

Posted at

C#でリソースを管理するクラスを作った時に
『CS0053 アクセシビリティに一貫性がありません。
プロパティ型 'Resources' のアクセシビリティはプロパティ 'ResourceManager.Resources' よりも低く設定されています。』
というエラーが出た。

コードとしては以下のような感じ。

リソース管理クラス
    public class ResourceManager : INotifyPropertyChanged
    {
        /// <summary>
        /// インスタンス
        /// </summary>
        public static ResourceManager Current { get; } = new ResourceManager();

        /// <summary>
        /// 多言語化されたリソース
        /// </summary>
        public Resources Resources { get; } = new Resources();

        /// ここから下は関係ないので省略
    }

エラーを見た時はResourceManagerクラスもResourcesプロパティも
『public』なので問題無いのに何故?と思ってたけどよくよくエラーを見ると
プロパティの方ではなくでResourcesクラスがダメだって書いてる。

で、原因はコレ↓
image.png

リソースのアクセス修飾子が『internal』になってる。
それを『public』として公開したのでエラーになっていたというオチ。

3
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0