jssblck
jssblck

Reputation: 529

Get and Set not being called

So I have a couple fields in a program that set the email subject and email body for an automated message.

My Email Settings class is this:

public static class Email
{
    public static string Body
    {
        get { return (string) SettingsStore.RetrieveSettingValue("emailBody"); }
        set { SettingsStore.StoreSetting(new Setting {SettingKey = "emailBody", 
                SettingValue = value}); }
    }

    public static string Subject
    {
        get { return (string) SettingsStore.RetrieveSettingValue("emailSubject"); }
        set { SettingsStore.StoreSetting(new Setting {SettingKey = "emailSubject",
                SettingValue = value}); }
    }
}

And my UI code that gets and sets the values is here:

private void ApplicationSettings_Load(object sender, EventArgs e)
{
    subjectTextEdit.Text = Settings.Email.Subject;
    bodyTextEdit.Text = Settings.Email.Body;
}

private void ApplicationSettings_FormClosing(object sender, FormClosingEventArgs e)
{
    Settings.Email.Subject = subjectTextEdit.Text;
    Settings.Email.Body = bodyTextEdit.Text;
}

Oddly, my get and set methods in the Email Settings class are not being called- when I access this form for the first time after application start the fields are blank even when the values are in the database. After I edit the fields once and close that form then open the form again (without closing the entire application) the fields have the text I put into them.

I have set a breakpoint on the _Load and _FormClosing events and these are getting hit. When I set a breakpoint on the get/set methods inside the settings class, the breakpoints are not getting hit.

Any ideas?

Upvotes: 0

Views: 185

Answers (1)

jssblck
jssblck

Reputation: 529

To everyone: Thanks for your help, I found the issue- the issue was Visual Studio, not the code.

I closed VS, restarted the PC, opened VS, cleaned the solution, closed, reopened, built. There was an error in one of my referenced assemblies that was not appearing all the other times I built the project that appeared this time, and fixing that error caused all of this to work properly.

I'd have never found this without your help (I'd still be scratching my head wondering how my code was wrong) so thank you all so much! :)

Upvotes: 3

Related Questions