Search code examples
c#monodevelopgtk#

MainWindow Vbox inaccessible due to its protection level


I am making a gtk# 2 application using Monodevelop.

I have made a simple GUI, with a Window and a Vbox as its child in order to use it from the runtime and add more stuff later on.

It seems though that i cannot access the vbox from the code.

This is the code:

namespace test
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Application.Init ();
            MainWindow win = new MainWindow ();
            TreeView tree = new TreeView ();
            Console.WriteLine(win.Child.Name);
            Mainvbox=win.vbox2;
...
}}}

The error i get is this: Error CS0122: `MainWindow.vbox2' is inaccessible due to its protection level (CS0122) (test)


Solution

  • vbox2 may be private/protected, write a property accessor to return it in MainWindow's class (or access it within MainWindow code).