tags:

views:

633

answers:

2

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' 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();
+2  A: 

You can't add:

  ResourcePolicyAvailSystemsLVI.m_nullString

because the scope of that member is either private or internal.

You need to make it public (or ideally, expose it via a property).

FlySwat
exactly thats my mistake,,actually there are two Listviews there i copied that from second listview to first listview where listview defined class is changedmore over need to declare the stringmeans like this public class ResourcePolicySystemsLVI : BaseLVItem { #region Fields private static string m_nullString = Managers.ControlStrings.GetString("ManagedDeviceWizard.None"); #endregion Fields
peter
+2  A: 

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

  • 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

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).


Re your comment; you have:

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

so just add:

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

and change your calling code to use ResourcePolicyAvailSystemsLVI.NullString.

Marc Gravell
exactly thats my mistake,,actually there are two Listviews there i copied that from second listview to first listview where listview defined class is changedmore over need to declare the stringmeans like this public class ResourcePolicySystemsLVI : BaseLVItem { #region Fields private static string m_nullString = Managers.ControlStrings.GetString("ManagedDeviceWizard.None"); #endregion Fields
peter