1

I'm having some issues with MySettings in Visual Studio.

I set up some settings via the GUI (properties menu). Give them names and values. Everything is saved.

Let's say I have a setting: SettingA, Value=123 (User settings)

I go to display SettingA in a textbox on Formload, and nothing happens. I go to display SettingA in a messagebox on Formload, nothing happens.

After the form loads up, if I code a button to display a setting in a textbox.... it does.

If, in code, I change the value of a setting and save it. Then have it display in a textbox, it will show the proper value.

If I close the app, and start it back up, it will either display nothing..or display an old value.

If I physically change a setting's value myself via the Properties menu of the project, then go to try to get the new value to display on Formload, or via button click.....either nothing will happen or it will still display an older value.

It seems that while the program is running, I can change values in code and have them display properly..whenever I want. After I close the program, I don't see any of the changes made in code reflect in the Properties menu.

This is just making no sense to me. If I physically changed a value myself, why won't it display/why is it still display the old value?

If I'm changing values in code, saving them in code, and then displaying them..why aren't they showing back in the Properties menu?

It's like changes just aren't being fully committed...or they are being read from more than 1 location.

Again, these are User settings.

The only code I have been using really are things like:

txtPort.Text = My.Settings.Port

My.Settings.Port = txtPort.text

My.Settings.Save()

Not necessarily in that order..just showing what I'm using.

Bill
  • 123
  • 1
  • 2
  • 14
  • 1
    `My.Settings.Port = txtPort.text` doesnt save the value back to Project -> Settings`= it will save them to file and load them the next time the app runs. values you type in are the initial/default values – Ňɏssa Pøngjǣrdenlarp Jul 10 '15 at 20:41
  • 1
    To sync up your settings file that your Debug application uses and the Visual Studio one, press the Synchronize button on the top left of the Project->Settings menu. – nilllzz Jul 10 '15 at 20:50

1 Answers1

0

It seems that you're changing the setting values during debug and then expecting to see those changes reflected in the development environment.

Here's the thing, the file that you're saving the settings in during debug is a copy of the file that you're working with in visual studio. It cannot affect the values inside of your visual studio project. The settings that you save will still be there the next time you debug only if you did not make any changes in the solution that require a rebuild.

If you want values that you enter via the properties window to show up in the debug then you will have to rebuild the application before debugging.

When you build the application to debug it, you're not running the program out of VS. VS creates an exe to run and runs it while retaining access to it's resources in order to give you feedback about the applications activities.

As nilllzz 7 stated, you can sync the VS Project settings to the settings in your debug files by clicking sync.

ThatGuy
  • 228
  • 1
  • 12