由于其保护级别而无法访问 [英] inaccessible due to its protection level

查看:516
本文介绍了由于其保护级别而无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在列表视图中显示version(WrmVersion)值,但是在这里我给出了一个条件 表示如果version(WrmVersion)为null,我正在显示'None'(ResourcePolicyAvailSystemsLVI.m_nullString ="None"),但现在我遇到了错误

i am displaying version(WrmVersion) value in a listview ,,but here i given one codition means if version(WrmVersion) is null i am displaying 'None'(ResourcePolicyAvailSystemsLVI.m_nullString="None"),,but now i am getting an error

"Ship.Controls.ResourcePolicySystemsControl.ResourcePolicyAvailSystemsLVI.m_nullString"由于其保护级别F而无法访问:\ test \ Ship \ Controls \ ResourcePolicySystemsControl.cs 81 70 Ship.Controls

'Ship.Controls.ResourcePolicySystemsControl.ResourcePolicyAvailSystemsLVI.m_nullString' is inaccessible due to its protection level F:\test\Ship\Controls\ResourcePolicySystemsControl.cs 81 70 Ship.Controls

protected override void OnUpdate()
         {
            string func = "ResourcePolicySystemsLVI.OnUpdate";
            try
            {
               if(Data != null)
               {
                  Text = base.Data.Name;
                  if(SubItems.Count == 1)
                  {
                      if (Data.WrmVersion == null)
                      {
                          SubItems.Add(ResourcePolicyAvailSystemsLVI.m_nullString);
                      }
                      else
                          **SubItems.Add(((IResourcePolicy)Data).WrmVersion.ToString());**
                     SubItems.Add(((IResourcePolicy)Data).ResourcePolicyEnabled.ToString());
                     SubItems.Add(((IResourcePolicy)Data).ResourcePolicyCurrent.ToString());
                     //SubItems.Add(((IResourcePolicy)Data).WrmVersion.ToString());
                     //SubItems.Add(Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Unisys\Single Point Operations Windows Resource Monitor", "CurrentVersion", "0").ToString()); 
                  }
                  else
                  {
                     SubItems[1].Text = ((IResourcePolicy)Data).ResourcePolicyEnabled.ToString();
                     SubItems[2].Text = ((IResourcePolicy)Data).ResourcePolicyCurrent.ToString();
                  }
               }
               base.OnUpdate();

推荐答案

那么,ResourcePolicyAvailSystemsLVI.m_nullString的保护级别是什么?您的代码在哪里?例如,如果将无法访问

Well, what is the protection level of ResourcePolicyAvailSystemsLVI.m_nullString ? And where is your code in relation? It will be inaccessible if, for example

  • 它是private,您在一个不相关的课程中
  • 它是protected,您不在子类中
  • 它是internal,并且您处于没有[InternalsVisibleTo]
  • 的其他程序集中
  • 它是protected internal,并且以上两个条件都适用
  • it is private and you're in an unrelated class
  • it is protected and you're not in a subclass
  • it is internal and you're in a different assembly without [InternalsVisibleTo]
  • it is protected internal and both of the two above apply

说实话,它看起来像一个字段,而一般字段不是public-因此,如果有人更改了辅助功能,这不会让我感到惊讶,也许添加一个公共静态属性来包装它-或简单地更改名称(尽管这会产生不同的错误).尝试寻找ResourcePolicyAvailSystemsLVI.NullString或类似的内容(在intellisense/object-browser中).

To be honest, it looks like a field, and fields generally aren't public - so it wouldn't amaze me if somebody has changed the accessibility, perhaps adding a public static property to wrap it - or simply changed the name (although that would give a different error). Try looking for ResourcePolicyAvailSystemsLVI.NullString or similar (in intellisense / object-browser).

发表您的评论;你有:

private static string m_nullString =
    Managers.ControlStrings.GetString("ManagedDeviceWizard.None");

所以只需添加:

public static string NullString {get {return m_nullString;}}

并更改您的呼叫代码以使用ResourcePolicyAvailSystemsLVI.NullString.

and change your calling code to use ResourcePolicyAvailSystemsLVI.NullString.

这篇关于由于其保护级别而无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆