1

I'm having an odd issue with Visual Studio 2019:

  1. Created a new project (vb.net console application / .NET 5.0)
  2. Goto > Project Properties
  3. The Settings Tab is missing (see picture)
  4. Manually create settings file (settings.settings)
  5. Add some application scoped settings
  6. Unable to access settings from within the program using my.settings.variable_name
  7. Can access the setting using project_name.settings.variable_name but getting a non-shared member requires object refrence error.

Is something hosed with my VS install? (I have 2017 as well, not having this issue)

settings.designer.vb:

    Namespace HL7_Pent
    
    <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(),  _
     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")>  _
    Partial Friend NotInheritable Class Settings
        Inherits Global.System.Configuration.ApplicationSettingsBase
        
        Private Shared defaultInstance As Settings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()),Settings)
        
        Public Shared ReadOnly Property [Default]() As Settings
            Get
                Return defaultInstance
            End Get
        End Property
        
        <Global.System.Configuration.ApplicationScopedSettingAttribute(),  _
         Global.System.Diagnostics.DebuggerNonUserCodeAttribute()>  _
        Public ReadOnly Property LastRun() As Date
            Get
                Return CType(Me("LastRun"),Date)
            End Get
        End Property
    End Class
End Namespace

Program.vb:

Sub Main(ByVal args As String())
    Dim LastRun = HL7_Pent.Settings.LastRun
End Sub

Error:

Reference to a non-shared member requies and object reference

DDulla
  • 659
  • 9
  • 20
  • .NET 5 is .NET Core, but you probably expected something similar to .NET Framework. .NET Core doesn't include a settings file. There is nothing wrong with your Visual Studio. [this](https://stackoverflow.com/q/65518159/832052) or [this](https://stackoverflow.com/questions/48858172/how-to-use-settings-files-in-net-core) may help – djv Jan 07 '22 at 16:19
  • *Manually create settings file (settings.settings)*? When the Settings file doesn't exist yet, you have the chance to click a link (a line of text colored in blue) to create a default `Settings.settings` file. Which is in the `My` namespace. You have a settings file with `Namespace HL7_Pent`. -- Use the standard procedure and you can access the settings with `My.Settings.LastRun` (no instance required) – Jimi Jan 09 '22 at 14:54

0 Answers0