1

I know there are many questions answered on Stack Overflow about this, so I wouldn't be asking this question if these solutions actually worked for me. Here are some of the questions I've looked at:

Inconsistent accessibility error C#

Inconsistent accessibility: property type

I've specified all of my classes as being public, as per each solution to the above questions, but I'm still getting the same error. Here is my code:

namespace TestResourceManager
{
    public class ViewModel
    {
        private List<string> m_ViewOptions = null;
        private List<MachineRow> m_ViewChoices = null;

        public ViewModel()
        {
            m_ViewOptions = new List<string>();
            m_ViewOptions.Add("item1");
            m_ViewOptions.Add("item2");
            m_ViewChoices.Add(new MachineRow("machinename1", "builddefinition1", "description1", "envname1", "envtype1"));
            m_ViewChoices.Add(new MachineRow("machinename2", "builddefinition2", "description2", "envname2", "envtype2"));
        }

        public List<string> ViewOptions
        {
            get { return m_ViewOptions; }
        }

        public List<MachineRow> ViewChoices
        {
            get { return m_ViewChoices; }
        }
    }
    public class MachineRow
    {
        private string MachineName, BuildDefinition, Description, EnvName, EnvType;

        public MachineRow(string _MachineName, string _BuildDefinition, string _Description, string _EnvName, string _EnvType)
        {
            this.MachineName = _MachineName;
            this.BuildDefinition = _BuildDefinition;
            this.Description = _Description;
            this.EnvName = _EnvName;
            this.EnvType = _EnvType;
        }
    }
}

This error:

Inconsistent accessibility: property type 'System.Collections.Generic.List<TestResourceManager.ViewModel.MachineRow>' is less accessible than property 'TestResourceManager.ViewModel.ViewChoices'

is occuring on this line:

public List<MachineRow> ViewChoices

Does anyone know why everyone else's solutions aren't working for my case? Any help much appreciated!

Community
  • 1
  • 1
t3hclwn
  • 37
  • 1
  • 7
  • 3
    The code compiles without any problem on my machine. Did you try a Rebuild or Clean/Build? – Pierre-Luc Pineault Jul 20 '13 at 00:05
  • 1
    Seems fine for me +1 for clean/rebuild. Maybe worth right clicking on `MachineRow` and navigating to the definition, on the off chance it sheds some light (in case a conflicting definition is to blame). – Chris Jul 20 '13 at 00:08
  • 1
    This isn't the full code - the error message is saying there's an inner class named `MachineRow` inside of `ViewModel` – Reed Copsey Jul 20 '13 at 00:08
  • @Pierre-LucPineault I did not try that and I feel dumb for not trying that. I will try it when I am back at my computer and report back. – t3hclwn Jul 20 '13 at 05:12
  • edit: posting this comment on @ReedCopsey's answer... – t3hclwn Jul 20 '13 at 05:14
  • @Pierre-LucPineault Cleaning and building worked, I never really realized that that could be the issue. Thanks for your help. The upvote button doesn't appear for me, so I can't +1 your comment. But that was the problem. – t3hclwn Jul 22 '13 at 17:28

1 Answers1

2

The code, as pasted, is not the complete code. Given the error message: System.Collections.Generic.List<TestResourceManager.**ViewModel**.MachineRow>, the issue is that there is an extra inner class, class MachineRow defined somewhere inside of your ViewModel class.

public class ViewModel
{
   // Somewhere before the closing brace, you're defining a MachineRow class that is not public, ie:
   class MachineRow {}
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373