My.Settings out of scope?
-
Hello to everyone, it might sound funny, but in a current project "suddenly" (i.e. I don't know what I exactly did) the references to "My.Settings" didn't work anymore. Instead, I had many errors saying that "Settings" isn't a property of "My". What I did: I opened a completely new (winforms-) project and looked into the files having "My.Settings" (etc) in their text, and adapted my project files "app.config", "settings.settings" and "settings.designer" (manually inserting the properties) to the syntax and entries I saw in the new (sample) project. First I thought it's ok: All the error messages disappeared. But when debugging, I can see that my settings references (e.g. "My.Settings.UserPath") only supply empty strings. This implies to me that the valid entries must be out of the valid scope (or something like that), i.e. I must have overlooked something... typos are checked. Could one of you please advise me, where else I might look for errors or what else I could do? Thank you very much in advance, Mick
-
Hello to everyone, it might sound funny, but in a current project "suddenly" (i.e. I don't know what I exactly did) the references to "My.Settings" didn't work anymore. Instead, I had many errors saying that "Settings" isn't a property of "My". What I did: I opened a completely new (winforms-) project and looked into the files having "My.Settings" (etc) in their text, and adapted my project files "app.config", "settings.settings" and "settings.designer" (manually inserting the properties) to the syntax and entries I saw in the new (sample) project. First I thought it's ok: All the error messages disappeared. But when debugging, I can see that my settings references (e.g. "My.Settings.UserPath") only supply empty strings. This implies to me that the valid entries must be out of the valid scope (or something like that), i.e. I must have overlooked something... typos are checked. Could one of you please advise me, where else I might look for errors or what else I could do? Thank you very much in advance, Mick
-
Go to PROJECT -> Properties on the VS menu. Or right click on the project in the Solution Explorer window and select Properties. You should then be able to navigate to the Settings section.
Thank you, Richard - but both methods work normal and I see the usual page with my user settings. The problem occurs when "InitializeComponent" calls
Private _userSourcePath As String = My.Settings.UserSourcePath <--------------
Public Property UserSourcePath() As String
Get...which is called by , returns an empty string instead of the actual settings entry. I think I must have made an error when manually editing the mentioned files. For example, I don't know where I would place the Namespace reference in "app.config" or in the settings files. Any other idea?
-
Thank you, Richard - but both methods work normal and I see the usual page with my user settings. The problem occurs when "InitializeComponent" calls
Private _userSourcePath As String = My.Settings.UserSourcePath <--------------
Public Property UserSourcePath() As String
Get...which is called by , returns an empty string instead of the actual settings entry. I think I must have made an error when manually editing the mentioned files. For example, I don't know where I would place the Namespace reference in "app.config" or in the settings files. Any other idea?
Sonhospa wrote:
Any other idea?
Sorry, no. But I would certainly not recommend manually editing these files, as it is too easy to make a mistake that does not show up until you try running the code. I can only suggest you recreate your project and settings via Visual Studio.
-
Sonhospa wrote:
Any other idea?
Sorry, no. But I would certainly not recommend manually editing these files, as it is too easy to make a mistake that does not show up until you try running the code. I can only suggest you recreate your project and settings via Visual Studio.
Thank you though, Richard. Finally I found the problem: The file "settings.designer.vb" had it's first part of the code (where the properties are defined) wrapped into "Namespace My"/"End Namespace". Obviously that's not right and lead to wrong references / empty string. Now it works again :thumbsup:! Have a nice day, Mick