VB.Net My.Settings is broken

Shane Brodie 0 Reputation points
2023-03-03T14:31:19.93+00:00

All of the My.Settings is broken. Synchronize does not work. Cannot add/edit new settings. Connection string settings all generate BC30469 error which I cannot resolve. Development status - dead stopped. Cannot build/debug due to errors.

VS 2022

.Net Framework 4.6.2

VB.Net

WinForms project

Sub New()
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.
    dm.ConnectionString = My.Settings.MaverickConnectionString 'BC30469 error
    dm.RootPath = My.Settings.VendorPath.Replace(vbCrLf, String.Empty) 'BC30469 error
    Try
        RefreshData()
    Catch ex As Exception
        XtraMessageBox.Show(Me, ex.Message, "Error Loading Data", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
End Sub
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,555 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shane Brodie 0 Reputation points
    2023-03-03T15:20:08.1266667+00:00

    For whatever reason, Settings.Designer.vb was auto-modified in a way that created this issue. I check with several other applications that were working correctly and compared the format of the Settings.Designer.vb file.

    What I found:

    In the application where the My.Settings objects were broken, the class "Settings" was contained within the namespace My.

    The bottom of this file also contained:

    Namespace My
        
        <Global.Microsoft.VisualBasic.HideModuleNameAttribute(),  _
         Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()>  _
        Friend Module MySettingsProperty
    
            <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")>
            Friend ReadOnly Property Settings() As Global.MaverickDesktop.My.Settings
                Get
                    Return Global.MaverickDesktop.Settings.Default
                End Get
            End Property
        End Module
    End Namespace
    

    Removing the first namespace entries around the Settings class and modifying the above to:

    Namespace My
        <Global.Microsoft.VisualBasic.HideModuleNameAttribute(),  _
         Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()>  _
        Friend Module MySettingsProperty
    
            <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")>
            Friend ReadOnly Property Settings() As Global.MaverickDesktop.Settings
               Get
                    Return Global.MaverickDesktop.Settings.Default
                End Get
            End Property
        End Module
    End Namespace
    

    This resolved the issue ... but doesn't give me a warm and fuzzy feeling.

    0 comments No comments