Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. My.Settings out of scope?

My.Settings out of scope?

Scheduled Pinned Locked Moved Visual Basic
csharpwinformshelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sonhospa
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • S Sonhospa

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • L Lost User

        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.

        S Offline
        S Offline
        Sonhospa
        wrote on last edited by
        #3

        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?

        L 1 Reply Last reply
        0
        • S Sonhospa

          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?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          S 1 Reply Last reply
          0
          • L Lost User

            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.

            S Offline
            S Offline
            Sonhospa
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups