0

I'm working on a project, that now needs to store something. Since I added a value to the settings (right-click project --> properties --> settings) I'm unable to build the software. The Settings.Designer.vb says a object reference is missing for My.Settings.Save(). Until now everything worked fine. Can anyone help?

EDIT:
Okay, literally one minute after posting this question i got it fixed, by changing My.Settings.Save() to My.Settings.Default.Save(). Can anyone explain?

  • You should start using source control immediately. That way, if anything goes haywire for whatever reason, you can simply revert to the last known good version. – jmcilhinney Oct 24 '22 at 13:21
  • @jmcilhinney I'm fighting for it, but my company thinks, this is not needed... – Enter name here Oct 24 '22 at 13:28
  • 2
    Depending on what level of control you have over what software is installed, you could run git locally even if there isn't anything "official". You wouldn't get the collaboration or resiliency benefits, but you would get the history-tracking benefits. – Craig Oct 24 '22 at 13:48

1 Answers1

1

Is the property scoped to User? Application-scoped properties cannot be saved at run time beecause the setting is scoped to Users by default. Also save my settings when closing in the project properties application tab is set to true by default, which means that My.Settings.Save is not required.

  • Yes, the property is scoped to the user, but the code making trouble is auto generated, so it isn't my choice to execute My.Settings.Save... I tried making changes, but the comment says it's auto generated and changes may get overwritten – Enter name here Oct 25 '22 at 13:23
  • Hello, is your problem solved now? – Hao Yu-MSFT Nov 11 '22 at 07:05
  • Hello, nope. With the workaround described i'm not getting any errors, but i still found no reason... – Enter name here Nov 14 '22 at 06:34
  • https://stackoverflow.com/questions/16881415/c-sharp-settings-default-save-not-saving Then you can take a look at this case, hope it helps you. – Hao Yu-MSFT Nov 21 '22 at 02:52
  • Nope, it did not help. The problem is not, that the data not getting stored. It gets stored. The problem is, that i'm getting an error "Object reference needed". After changing ```My.Settings.Save()``` to ```My.Settings.Default.Save()``` i fixed the error, but i want to understand the reason... – Enter name here Nov 22 '22 at 06:52