Okay so this has been bugging me for quite sometime. I thought if I skipped it and came back maybe I might figure it out but I guess not. The basic idea is to let the user generate their own content into a list box, text box, and the content still be there the next time the user opens the program. Like, say I want to make an archive. I give the user an option to create a name for whatever they are storing and store that to a list box, then store whatever they put into the rich text box gets stored for call by the name in the list box. Only one problem with it so far... I seem to be missing a reference and can't figure out where it is or how to include it...

void button2_Click(object sender, EventArgs e)
        {
             storage.Text = userStore.Properties.Settings.storage;

             if (display.Text == "")
             {
                  MessageBox.Show("Please put something into the text box for us to store with the name you gave.");
             }
             else
             {
                 storage.Text = display.Text;
                 userStore.Properties.Settings.storage = display.Text;
                 userStore.Properties.Settings.Save();
             }
        }

An object reference is required for the non-static field, method, or property 'userStore.Properties.Settings.storage.get'

That's the error I get at compiling. There are two others just like it but for the other two lines that say the same thing. Please help. I've looked everywhere and can't figure it out.

Recommended Answers

All 3 Replies

It looks like you are calling a non static property from a static method. Make the method static or create an instance of the class before calling the method..... just check where in the code you are doing that.... Check all functions starting with the keyword static. Don't call any static member with its class name directly instead make its object first

I fixed it already thanks for the help though. Problem was I wasn't creating a new instance before using the settings.


userStore.Properties.Settings mySettings = new userStore.Properties.Settings();

That's the line that fixed it all. Minus a few of the obvious fixes after entering it. :D

:) Congrats

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.