问:
ToolStripItems not Showing Up
To make it short, I've developed an application and at its final stages I thought about creating a form for the first run of the application, where the user (admin) will set up some control variables.

In order to achieve this functionality, I had to make sure that there was a form that would control if the user was 'seeing' the application for the first time or not, calling it a ghost form (this form won't be visible).

This 'ghost' form will check if the variable FirstRun is true or not. If it's true, a form to set up the control variables will be called, otherwise the main form of the application will be launched:

```<code>Public Class fGhostForm

    Private Sub fGhostForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Close()
    End Sub

    Private Sub fGhostForm_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        If My.Settings.FirstRun Then
            Dim FormToLaunch As fFirstRunApplicationSettings = New fFirstRunApplicationSettings()
            FormToLaunch.ShowDialog()
        Else
            Dim FormToLaunch As fMainForm = New fMainForm()
            FormToLaunch.ShowDialog()
        End If
    End Sub
End Class
</code>```

This works fine and dandy as I can see my main form on its primary state, meaning that I'm currently a guest user that currently has almost no access to any functionality of the application.
In order to get access, I need to first log in into my database and I do that by clicking the option "Iniciar Sessão" and a new form pops up where the user must input his credentials:

2.png

After the login, according to which level of security the user has, new toolstripitems must appear on the menustrip of the main form.
Now here's the problem:

If I set the "fMainForm" to be the startup form for the project, this is the scenario that occurs.
However, if I set the "fGhostForm" to be the startup form, I do get to see the main form popping up, but after the login, the toolstripitems do not show up at all.

To isolate the problem, I decided to create a test button, just to create a new instance of the main form, calling an exact copy of it.
Now, when I perform the login step, on the main form that was called from pressing the test button, the toolstripitems do not show up.
However, on the first main form, the toolstripitems do show up as their supposed to (I did this with the "fMainForm" as the startup form for the project):

3.png

4.png

5.png

6.png

This is the test button code:

```<code>Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim testForm As fMainForm = New fMainForm()
    testForm.Show()
End Sub
</code>```

I can't make heads or tails of what causes this behaviour. Does anyone have any idea of why this is happening?
I can offer more details if needed.

P.S. The main form is an MdiContainer and I have also checked the AllowMerge property for the menustrip, disabling it, but the result is still the same.

Edit*
I just realised that I didn't post the main form's load event nor the login event and I apologize for the confusion it may have caused.
Here it is:

```Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
    currentOp = "Low Database"

    Try
        Dim taLogins As New RecipeMasterDBDataSetTableAdapters.LoginsTableAdapter
        Dim tLogins As New RecipeMasterDBDataSet.LoginsDataTable
        Dim PED As cPassEncrypterDecrypter
        PED = New cPassEncrypterDecrypter()

        If taLogins.FillByLoginAuthByUsernamePassword(tLogins, txtUsername.Text, PED.StringEncrypter(txtPassword.Text)) > 0 Then
            Dim taSessions As New RecipeMasterDBDataSetTableAdapters.SessionsTableAdapter
            Dim tSession As New RecipeMasterDBDataSet.SessionsDataTable
            taSessions.InsertQuerySession(Date.Now.Date & " " & Date.Now.Hour & ":" & Date.Now.Minute & ":" & Date.Now.Second, CInt(tLogins.Rows(0).Item(0)))

            fMainForm.CurrentUserSessionID = taSessions.SelectQueryCurrentSession(CInt(tLogins.Rows(0).Item(0)))
            If tLogins.Rows(0).Item(4) Then
                Dim taRecipes As New RecipeMasterDBDataSetTableAdapters.RecipesTableAdapter
                Dim tRecipes As New RecipeMasterDBDataSet.RecipesDataTable
                Dim taRatings As New RecipeMasterDBDataSetTableAdapters.RatingsTableAdapter

                taRecipes.Fill(tRecipes)
                taEvents.InsertQueryEvents("SELECT Statement - Login Interface", "Query: Generic query | Parameters - N/A" _
                                          , Date.Now, "Form: " & Me.Name & "Site: btnLogin_Click", _
                                          CInt(tLogins.Rows(0).Item(0)), 28)
                For recipeIndex As Integer = 0 To tRecipes.Rows.Count - 1
                    If My.Settings.ChosenLanguageIndex = 0 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Ainda não comentada", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Ainda não comentada " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 1 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Not yet commented", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Not yet commented " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 2 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Pas encore de commentaires", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Pas encore engagé " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 3 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Aún no ha comentado", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Aún no ha comentado " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 4 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Non ancora commentato", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Non ancora commentato " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 5 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Noch nicht kommentiert", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Noch nicht kommentiert " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    End If
                Next
                taLogins.UpdateQueryFirstLoginFlag(False, txtUsername.Text)
                taEvents.InsertQueryEvents("UPDATE Transaction - Login Interface", _
                                          "Procedure: UpdateQueryFirstLoginFlag | Parameters - " & _
                                          "IsFirstLogin: " & "False " & "Username: " & txtUsername.Text, Date.Now, _
                                          "Form: " & Me.Name & " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
            End If

            fMainForm.ChefesToolStripMenuItem.Enabled = True
            fMainForm.ChefesToolStripMenuItem.Visible = True
            fMainForm.ReceitasToolStripMenuItem.Enabled = True
            fMainForm.ReceitasToolStripMenuItem.Visible = True
            fMainForm.AvaliaçõesToolStripMenuItem.Enabled = True
            fMainForm.AvaliaçõesToolStripMenuItem.Visible = True
            'fMainForm.GestõesMassivasToolStripMenuItem.Enabled = False
            'fMainForm.GestõesMassivasToolStripMenuItem.Visible = False
            fMainForm.ToolStripSeparator5.Visible = True
            fMainForm.AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Enabled = True
            fMainForm.AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Visible = True
            fMainForm.SuporteTécnicoToolStripMenuItem.Enabled = True
            fMainForm.SuporteTécnicoToolStripMenuItem.Visible = True
            'fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
            'fMainForm.AdministraçãoToolStripMenuItem.Visible = False

            taLogins.UpdateQueryLastLoginTimeStamp(CDate(Date.Now), txtUsername.Text)
            taEvents.InsertQueryEvents("UPDATE Transaction - Login Interface", _
                                          "Procedure: UpdateQueryLastLoginTimeStamp | Parameters - " & _
                                          "LAST_LOGIN_TIMESTAMP: " & CDate(Date.Now) & " Username: " & txtUsername.Text, Date.Now, _
                                          "Form: " & Me.Name & " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)

            If CInt(tLogins.Rows(0).Item(7)) >= 1 And CInt(tLogins.Rows(0).Item(7)) <= 3 Then
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = True
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = True
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = True
                fMainForm.AdministraçãoToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator2.Visible = True
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = True
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator6.Visible = True
                fMainForm.FotografiasToolStripMenuItem.Enabled = True
                fMainForm.FotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator9.Visible = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = True
            ElseIf CInt(tLogins.Rows(0).Item(7)) >= 4 And CInt(tLogins.Rows(0).Item(7)) <= 5 Then
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = True
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = True
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
                fMainForm.AdministraçãoToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator2.Visible = True
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = True
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator6.Visible = True
                fMainForm.FotografiasToolStripMenuItem.Enabled = True
                fMainForm.FotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator9.Visible = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = True
            ElseIf CInt(tLogins.Rows(0).Item(7)) = 6 Then
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = False
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = False
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
                fMainForm.AdministraçãoToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator2.Visible = True
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = True
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator6.Visible = False
                fMainForm.FotografiasToolStripMenuItem.Enabled = False
                fMainForm.FotografiasToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator9.Visible = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = False
            Else
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = False
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = False
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
                fMainForm.AdministraçãoToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator2.Visible = False
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = False
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator6.Visible = False
                fMainForm.FotografiasToolStripMenuItem.Enabled = False
                fMainForm.FotografiasToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator9.Visible = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = False
            End If

            fMainForm.CurrentUser = CStr(tLogins.Rows(0).Item(1))
            AuthSessionValid = True
            Me.Close()
        Else
            numberOfLoginFailedAttempts += 1
            If My.Settings.ChosenLanguageIndex = 0 Then
                MessageBox.Show("As credenciais que introduziu estão incorrectas." & ControlChars.CrLf & "Por favor, tente novamente." _
                            , "Erro: Credenciais Inválidas", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 1 Then
                MessageBox.Show("The credentials you entered are incorrect." & ControlChars.CrLf & "Please, try again." _
                            , "Error: Invalid Credentials", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 2 Then
                MessageBox.Show("Les informations d'identification que vous avez inscrits sont incorrects." & ControlChars.CrLf & "Veuillez réessayer." _
                            , "Erreur: Lettres de Créance non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 3 Then
                MessageBox.Show("Las credenciales que ha introducido son incorrectos." & ControlChars.CrLf & "Por favor, inténtelo de nuevo." _
                            , "Error: Credenciales no Válidas", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 4 Then
                MessageBox.Show("Le credenziali immesse non sono corrette." & ControlChars.CrLf & "Si prega, riprovare." _
                            , "Errore: Credenziali non Valide", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 5 Then
                MessageBox.Show("Die Anmeldeinformationen eingegeben sind falsch." & ControlChars.CrLf & "Bitte versuche es erneut." _
                            , "Fehler: Ungültige Anmeldeinformationen ", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If

            If numberOfLoginFailedAttempts > 5 Then
                btnLogin.Enabled = False
                If My.Settings.ChosenLanguageIndex = 0 Then
                    Throw New Exception("O início de sessão foi bloqueado durante 30 segundos, devido ao número abusivo de tentativas." & ControlChars.CrLf & "Por favor, aguarde...")
                ElseIf My.Settings.ChosenLanguageIndex = 1 Then
                    Throw New Exception("Session start was blocked for 30 seconds due to abusive attempts." & ControlChars.CrLf & "Please wait...")
                ElseIf My.Settings.ChosenLanguageIndex = 2 Then
                    Throw New Exception("Le démarrage de la session a été bloqué pendant 30 secondes en raison de tentatives abusives." & ControlChars.CrLf & "S'il vous plaît, attendez...")
                ElseIf My.Settings.ChosenLanguageIndex = 3 Then
                    Throw New Exception("El inicio de sesión se bloqueó durante 30 segundos debido a intentos abusivos." & ControlChars.CrLf & "Por favor, espere...")
                ElseIf My.Settings.ChosenLanguageIndex = 4 Then
                    Throw New Exception("Inizia di la sessione è stata bloccata per 30 secondi a causa di tentativi abusivi." & ControlChars.CrLf & "Attendere prego...")
                ElseIf My.Settings.ChosenLanguageIndex = 5 Then
                    Throw New Exception("Der Sitzungsstart wurde wegen missbräuchlicher, Versuche für 30 Sekunden blockiert." & ControlChars.CrLf & "Warten Sie mal...")
                End If
            End If
        End If
    Catch ex As Exception
        Dim taLogins As New RecipeMasterDBDataSetTableAdapters.LoginsTableAdapter
        Dim tLogins As New RecipeMasterDBDataSet.LoginsDataTable
        Dim taEvents As New RecipeMasterDBDataSetTableAdapters.AppEventsTableAdapter
        Dim tEvents As New RecipeMasterDBDataSet.LoginsDataTable

        taLogins.FillByLoginByUsername(tLogins, "Admin")
        taEvents.InsertQueryEvents(currentOp & " Error - Multiple Failed Login Attempts", "Code Error: " & ex.HResult & " | Error Description: " & ex.Message & " | Source: " & _
        ex.Source, Date.Now, "Site: " & ex.TargetSite.Name, CInt(tLogins.Rows(0).Item(0)), 10)

        If My.Settings.ChosenLanguageIndex = 0 Then
            MessageBox.Show("Ocorreu a seguinte excepção:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Rastreamento de Pilha: " & ex.StackTrace, "Erro de Sistema: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 1 Then
            MessageBox.Show("The following exception occurred:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Stack Trace: " & ex.StackTrace, "System Error: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 2 Then
            MessageBox.Show("L'exception suivante s'est produite:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Trace de la Pile: " & ex.StackTrace, "Erreur de Système: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 3 Then
            MessageBox.Show("Se produjo la siguiente excepción:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Rastro de la Pila: " & ex.StackTrace, "Error del Sistema: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 4 Then
            MessageBox.Show("Si è verificato il seguente eccezione:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Analisi dello Stack: " & ex.StackTrace, "Errore di Sistema: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 5 Then
            MessageBox.Show("Die folgende Ausnahme ist aufgetreten:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Stapelüberwachung: " & ex.StackTrace, "Systemfehler: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
        tmrFailedLoginAttemptsController.Start()
    End Try
End Sub
```

<p><strong>Here's the main form's load event:</strong></p>

```Private Sub fMainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Try
        LastVisitedForm = Me.Text

        currentOp = "High System"

        If Not Directory.Exists(My.Settings.BackupFilesFolderPath) Then
            Throw New Exception("The backup files folder either was moved or is missing from this computer." & ControlChars.CrLf & _
        "Check your application folders for any misspeled names.")
            Application.Exit()
        End If

        If Not Directory.Exists(My.Settings.DBPath) Then
            Throw New Exception("The database files folder either was moved or is missing from this computer." & ControlChars.CrLf & _
    "Check your application folders for any misspeled names.")
            Application.Exit()
        End If

        If My.Settings.BackupFilesFolderPath = String.Empty Then
            My.Settings.BackupFilesFolderPath =
Application.StartupPath.Remove(Application.StartupPath.Length - 10) & "\Backup Files"
            My.Settings.Save()
        End If

        If My.Settings.DBPath = String.Empty Then
            My.Settings.DBPath = "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA" 'temp folder
            My.Settings.Save()
        End If

        If My.Settings.DBFileName = String.Empty Then
            My.Settings.DBFileName = "RecipeMasterDB.mdf"
            My.Settings.Save()
        End If

        Me.Text = "Recipe Master"

        JanelasToolStripMenuItem.Enabled = False

        EmailAccountCheckSumArray = New List(Of String)

        'System clock code...

        'Synchronize time always on application startup

        secondsController = CDate(My.Settings.AppCurTime).Second
        minutesController = CDate(My.Settings.AppCurTime).Minute
        hoursController = CDate(My.Settings.AppCurTime).Hour
        daysController = CDate(My.Settings.AppCurTime).Day
        monthsController = CDate(My.Settings.AppCurTime).Month
        yearsController = CDate(My.Settings.AppCurTime).Year

        SystemClockStartUp = True
        tmrAppTimeController.Start()

        LanguageInterpreter(My.Settings.ChosenLanguageIndex)

        ChefesToolStripMenuItem.Enabled = False
        ChefesToolStripMenuItem.Visible = False
        ReceitasToolStripMenuItem.Enabled = False
        ReceitasToolStripMenuItem.Visible = False
        AvaliaçõesToolStripMenuItem.Enabled = False
        AvaliaçõesToolStripMenuItem.Visible = False
        GestõesMassivasToolStripMenuItem.Enabled = False
        GestõesMassivasToolStripMenuItem.Visible = False
        ToolStripSeparator5.Visible = False
        AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Enabled = False
        AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Visible = False
        SuporteTécnicoToolStripMenuItem.Enabled = False
        SuporteTécnicoToolStripMenuItem.Visible = False
        AdministraçãoToolStripMenuItem.Enabled = False
        AdministraçãoToolStripMenuItem.Visible = False
    Catch ex As Exception
        'exception handling code ...
    End Try
End Sub
```

答:
Thanks to TnTinMn, the answer lied in simply instantiating the main form on the Ghost Form, while declaring the variable as public shared variable.
Then all that was required was to call the menustripitems through that variable.

Code for load event of Ghost Form:

```<code>Public Class fGhostForm

    Public Shared MainForm As fMainForm

    Private Sub fGhostForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Close()
    End Sub

    Private Sub fGhostForm_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        If My.Settings.FirstRun Then
            Dim FormToLaunch As fFirstRunApplicationSettings = New fFirstRunApplicationSettings()
            FormToLaunch.ShowDialog()
        Else
            MainForm = New fMainForm()
            MainForm.ShowDialog()
        End If
    End Sub
End Class
</code>```

Code to call and control the menustripitems:

```<code>fGhostForm.MainForm.ChefesToolStripMenuItem.Enabled = True
fGhostForm.MainForm.ChefesToolStripMenuItem.Visible = True
</code>```

Thanks everyone for their time.

Title: ToolStripItems not Showing Up

Body:
To make it short, I've developed an application and at its final stages I thought about creating a form for the first run of the application, where the user (admin) will set up some control variables.

In order to achieve this functionality, I had to make sure that there was a form that would control if the user was 'seeing' the application for the first time or not, calling it a ghost form (this form won't be visible).

This 'ghost' form will check if the variable FirstRun is true or not. If it's true, a form to set up the control variables will be called, otherwise the main form of the application will be launched:

Public Class fGhostForm

    Private Sub fGhostForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Close()
    End Sub

    Private Sub fGhostForm_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        If My.Settings.FirstRun Then
            Dim FormToLaunch As fFirstRunApplicationSettings = New fFirstRunApplicationSettings()
            FormToLaunch.ShowDialog()
        Else
            Dim FormToLaunch As fMainForm = New fMainForm()
            FormToLaunch.ShowDialog()
        End If
    End Sub
End Class

This works fine and dandy as I can see my main form on its primary state, meaning that I'm currently a guest user that currently has almost no access to any functionality of the application.
In order to get access, I need to first log in into my database and I do that by clicking the option "Iniciar Sessão" and a new form pops up where the user must input his credentials:

2.png

After the login, according to which level of security the user has, new toolstripitems must appear on the menustrip of the main form.
Now here's the problem:

If I set the "fMainForm" to be the startup form for the project, this is the scenario that occurs.
However, if I set the "fGhostForm" to be the startup form, I do get to see the main form popping up, but after the login, the toolstripitems do not show up at all.

To isolate the problem, I decided to create a test button, just to create a new instance of the main form, calling an exact copy of it.
Now, when I perform the login step, on the main form that was called from pressing the test button, the toolstripitems do not show up.
However, on the first main form, the toolstripitems do show up as their supposed to (I did this with the "fMainForm" as the startup form for the project):

3.png

4.png

5.png

6.png

This is the test button code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim testForm As fMainForm = New fMainForm()
    testForm.Show()
End Sub

I can't make heads or tails of what causes this behaviour. Does anyone have any idea of why this is happening?
I can offer more details if needed.

P.S. The main form is an MdiContainer and I have also checked the AllowMerge property for the menustrip, disabling it, but the result is still the same.

Edit*
I just realised that I didn't post the main form's load event nor the login event and I apologize for the confusion it may have caused.
Here it is:

Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
    currentOp = "Low Database"

    Try
        Dim taLogins As New RecipeMasterDBDataSetTableAdapters.LoginsTableAdapter
        Dim tLogins As New RecipeMasterDBDataSet.LoginsDataTable
        Dim PED As cPassEncrypterDecrypter
        PED = New cPassEncrypterDecrypter()

        If taLogins.FillByLoginAuthByUsernamePassword(tLogins, txtUsername.Text, PED.StringEncrypter(txtPassword.Text)) > 0 Then
            Dim taSessions As New RecipeMasterDBDataSetTableAdapters.SessionsTableAdapter
            Dim tSession As New RecipeMasterDBDataSet.SessionsDataTable
            taSessions.InsertQuerySession(Date.Now.Date & " " & Date.Now.Hour & ":" & Date.Now.Minute & ":" & Date.Now.Second, CInt(tLogins.Rows(0).Item(0)))

            fMainForm.CurrentUserSessionID = taSessions.SelectQueryCurrentSession(CInt(tLogins.Rows(0).Item(0)))
            If tLogins.Rows(0).Item(4) Then
                Dim taRecipes As New RecipeMasterDBDataSetTableAdapters.RecipesTableAdapter
                Dim tRecipes As New RecipeMasterDBDataSet.RecipesDataTable
                Dim taRatings As New RecipeMasterDBDataSetTableAdapters.RatingsTableAdapter

                taRecipes.Fill(tRecipes)
                taEvents.InsertQueryEvents("SELECT Statement - Login Interface", "Query: Generic query | Parameters - N/A" _
                                          , Date.Now, "Form: " & Me.Name & "Site: btnLogin_Click", _
                                          CInt(tLogins.Rows(0).Item(0)), 28)
                For recipeIndex As Integer = 0 To tRecipes.Rows.Count - 1
                    If My.Settings.ChosenLanguageIndex = 0 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Ainda não comentada", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Ainda não comentada " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 1 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Not yet commented", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Not yet commented " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 2 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Pas encore de commentaires", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Pas encore engagé " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 3 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Aún no ha comentado", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Aún no ha comentado " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 4 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Non ancora commentato", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Non ancora commentato " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    ElseIf My.Settings.ChosenLanguageIndex = 5 Then
                        taRatings.InsertQueryBaseRatingsForUser(Nothing, "Noch nicht kommentiert", 0, 0D, False, "1900-01-01", CInt(tLogins.Rows(0).Item(0)), CInt(tRecipes.Rows(recipeIndex).Item(0)))
                        taEvents.InsertQueryEvents("INSERT Transaction - Login Interface", _
                                                  "Procedure: InsertQueryBaseRatingsForUser | Parameters - " & _
                                                  "Comment: " & String.Empty & " Comment_Flag: " & " Noch nicht kommentiert " & _
                                                  "Rate_Level: " & 0 & " Rate_Score_Index: " & 0D & "Rated_Flag: " & _
                                                  "False " & "Rate_Recent_Date: " & "1900-01-01 " & "Login ID: " & _
                                                  CInt(tLogins.Rows(0).Item(0)) & " Recipe ID: " & _
                                                  CInt(tRecipes.Rows(recipeIndex).Item(0)), Date.Now, "Form: " & Me.Name & _
                                                  " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
                    End If
                Next
                taLogins.UpdateQueryFirstLoginFlag(False, txtUsername.Text)
                taEvents.InsertQueryEvents("UPDATE Transaction - Login Interface", _
                                          "Procedure: UpdateQueryFirstLoginFlag | Parameters - " & _
                                          "IsFirstLogin: " & "False " & "Username: " & txtUsername.Text, Date.Now, _
                                          "Form: " & Me.Name & " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)
            End If

            fMainForm.ChefesToolStripMenuItem.Enabled = True
            fMainForm.ChefesToolStripMenuItem.Visible = True
            fMainForm.ReceitasToolStripMenuItem.Enabled = True
            fMainForm.ReceitasToolStripMenuItem.Visible = True
            fMainForm.AvaliaçõesToolStripMenuItem.Enabled = True
            fMainForm.AvaliaçõesToolStripMenuItem.Visible = True
            'fMainForm.GestõesMassivasToolStripMenuItem.Enabled = False
            'fMainForm.GestõesMassivasToolStripMenuItem.Visible = False
            fMainForm.ToolStripSeparator5.Visible = True
            fMainForm.AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Enabled = True
            fMainForm.AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Visible = True
            fMainForm.SuporteTécnicoToolStripMenuItem.Enabled = True
            fMainForm.SuporteTécnicoToolStripMenuItem.Visible = True
            'fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
            'fMainForm.AdministraçãoToolStripMenuItem.Visible = False

            taLogins.UpdateQueryLastLoginTimeStamp(CDate(Date.Now), txtUsername.Text)
            taEvents.InsertQueryEvents("UPDATE Transaction - Login Interface", _
                                          "Procedure: UpdateQueryLastLoginTimeStamp | Parameters - " & _
                                          "LAST_LOGIN_TIMESTAMP: " & CDate(Date.Now) & " Username: " & txtUsername.Text, Date.Now, _
                                          "Form: " & Me.Name & " Site: btnLogin_Click", CInt(tLogins.Rows(0).Item(0)), 31)

            If CInt(tLogins.Rows(0).Item(7)) >= 1 And CInt(tLogins.Rows(0).Item(7)) <= 3 Then
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = True
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = True
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = True
                fMainForm.AdministraçãoToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator2.Visible = True
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = True
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator6.Visible = True
                fMainForm.FotografiasToolStripMenuItem.Enabled = True
                fMainForm.FotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator9.Visible = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = True
            ElseIf CInt(tLogins.Rows(0).Item(7)) >= 4 And CInt(tLogins.Rows(0).Item(7)) <= 5 Then
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = True
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = True
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
                fMainForm.AdministraçãoToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator2.Visible = True
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = True
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator6.Visible = True
                fMainForm.FotografiasToolStripMenuItem.Enabled = True
                fMainForm.FotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator9.Visible = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = True
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = True
            ElseIf CInt(tLogins.Rows(0).Item(7)) = 6 Then
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = False
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = False
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
                fMainForm.AdministraçãoToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator2.Visible = True
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = True
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = True
                fMainForm.ToolStripSeparator6.Visible = False
                fMainForm.FotografiasToolStripMenuItem.Enabled = False
                fMainForm.FotografiasToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator9.Visible = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = False
            Else
                fMainForm.GestõesMassivasToolStripMenuItem.Enabled = False
                fMainForm.GestõesMassivasToolStripMenuItem.Visible = False
                fMainForm.AdministraçãoToolStripMenuItem.Enabled = False
                fMainForm.AdministraçãoToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator2.Visible = False
                fMainForm.GerirFotografiasToolStripMenuItem.Enabled = False
                fMainForm.GerirFotografiasToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator6.Visible = False
                fMainForm.FotografiasToolStripMenuItem.Enabled = False
                fMainForm.FotografiasToolStripMenuItem.Visible = False
                fMainForm.ToolStripSeparator9.Visible = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Enabled = False
                fMainForm.GeradorDeModelosToolStripMenuItem.Visible = False
            End If

            fMainForm.CurrentUser = CStr(tLogins.Rows(0).Item(1))
            AuthSessionValid = True
            Me.Close()
        Else
            numberOfLoginFailedAttempts += 1
            If My.Settings.ChosenLanguageIndex = 0 Then
                MessageBox.Show("As credenciais que introduziu estão incorrectas." & ControlChars.CrLf & "Por favor, tente novamente." _
                            , "Erro: Credenciais Inválidas", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 1 Then
                MessageBox.Show("The credentials you entered are incorrect." & ControlChars.CrLf & "Please, try again." _
                            , "Error: Invalid Credentials", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 2 Then
                MessageBox.Show("Les informations d'identification que vous avez inscrits sont incorrects." & ControlChars.CrLf & "Veuillez réessayer." _
                            , "Erreur: Lettres de Créance non Valides", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 3 Then
                MessageBox.Show("Las credenciales que ha introducido son incorrectos." & ControlChars.CrLf & "Por favor, inténtelo de nuevo." _
                            , "Error: Credenciales no Válidas", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 4 Then
                MessageBox.Show("Le credenziali immesse non sono corrette." & ControlChars.CrLf & "Si prega, riprovare." _
                            , "Errore: Credenziali non Valide", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf My.Settings.ChosenLanguageIndex = 5 Then
                MessageBox.Show("Die Anmeldeinformationen eingegeben sind falsch." & ControlChars.CrLf & "Bitte versuche es erneut." _
                            , "Fehler: Ungültige Anmeldeinformationen ", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If

            If numberOfLoginFailedAttempts > 5 Then
                btnLogin.Enabled = False
                If My.Settings.ChosenLanguageIndex = 0 Then
                    Throw New Exception("O início de sessão foi bloqueado durante 30 segundos, devido ao número abusivo de tentativas." & ControlChars.CrLf & "Por favor, aguarde...")
                ElseIf My.Settings.ChosenLanguageIndex = 1 Then
                    Throw New Exception("Session start was blocked for 30 seconds due to abusive attempts." & ControlChars.CrLf & "Please wait...")
                ElseIf My.Settings.ChosenLanguageIndex = 2 Then
                    Throw New Exception("Le démarrage de la session a été bloqué pendant 30 secondes en raison de tentatives abusives." & ControlChars.CrLf & "S'il vous plaît, attendez...")
                ElseIf My.Settings.ChosenLanguageIndex = 3 Then
                    Throw New Exception("El inicio de sesión se bloqueó durante 30 segundos debido a intentos abusivos." & ControlChars.CrLf & "Por favor, espere...")
                ElseIf My.Settings.ChosenLanguageIndex = 4 Then
                    Throw New Exception("Inizia di la sessione è stata bloccata per 30 secondi a causa di tentativi abusivi." & ControlChars.CrLf & "Attendere prego...")
                ElseIf My.Settings.ChosenLanguageIndex = 5 Then
                    Throw New Exception("Der Sitzungsstart wurde wegen missbräuchlicher, Versuche für 30 Sekunden blockiert." & ControlChars.CrLf & "Warten Sie mal...")
                End If
            End If
        End If
    Catch ex As Exception
        Dim taLogins As New RecipeMasterDBDataSetTableAdapters.LoginsTableAdapter
        Dim tLogins As New RecipeMasterDBDataSet.LoginsDataTable
        Dim taEvents As New RecipeMasterDBDataSetTableAdapters.AppEventsTableAdapter
        Dim tEvents As New RecipeMasterDBDataSet.LoginsDataTable

        taLogins.FillByLoginByUsername(tLogins, "Admin")
        taEvents.InsertQueryEvents(currentOp & " Error - Multiple Failed Login Attempts", "Code Error: " & ex.HResult & " | Error Description: " & ex.Message & " | Source: " & _
        ex.Source, Date.Now, "Site: " & ex.TargetSite.Name, CInt(tLogins.Rows(0).Item(0)), 10)

        If My.Settings.ChosenLanguageIndex = 0 Then
            MessageBox.Show("Ocorreu a seguinte excepção:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Rastreamento de Pilha: " & ex.StackTrace, "Erro de Sistema: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 1 Then
            MessageBox.Show("The following exception occurred:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Stack Trace: " & ex.StackTrace, "System Error: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 2 Then
            MessageBox.Show("L'exception suivante s'est produite:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Trace de la Pile: " & ex.StackTrace, "Erreur de Système: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 3 Then
            MessageBox.Show("Se produjo la siguiente excepción:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Rastro de la Pila: " & ex.StackTrace, "Error del Sistema: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 4 Then
            MessageBox.Show("Si è verificato il seguente eccezione:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Analisi dello Stack: " & ex.StackTrace, "Errore di Sistema: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf My.Settings.ChosenLanguageIndex = 5 Then
            MessageBox.Show("Die folgende Ausnahme ist aufgetreten:" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ControlChars.CrLf & _
            "Stapelüberwachung: " & ex.StackTrace, "Systemfehler: " & ex.HResult, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
        tmrFailedLoginAttemptsController.Start()
    End Try
End Sub

Here's the main form's load event:

Private Sub fMainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Try
        LastVisitedForm = Me.Text

        currentOp = "High System"

        If Not Directory.Exists(My.Settings.BackupFilesFolderPath) Then
            Throw New Exception("The backup files folder either was moved or is missing from this computer." & ControlChars.CrLf & _
        "Check your application folders for any misspeled names.")
            Application.Exit()
        End If

        If Not Directory.Exists(My.Settings.DBPath) Then
            Throw New Exception("The database files folder either was moved or is missing from this computer." & ControlChars.CrLf & _
    "Check your application folders for any misspeled names.")
            Application.Exit()
        End If

        If My.Settings.BackupFilesFolderPath = String.Empty Then
            My.Settings.BackupFilesFolderPath =
Application.StartupPath.Remove(Application.StartupPath.Length - 10) & "\Backup Files"
            My.Settings.Save()
        End If

        If My.Settings.DBPath = String.Empty Then
            My.Settings.DBPath = "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA" 'temp folder
            My.Settings.Save()
        End If

        If My.Settings.DBFileName = String.Empty Then
            My.Settings.DBFileName = "RecipeMasterDB.mdf"
            My.Settings.Save()
        End If

        Me.Text = "Recipe Master"

        JanelasToolStripMenuItem.Enabled = False

        EmailAccountCheckSumArray = New List(Of String)

        'System clock code...

        'Synchronize time always on application startup

        secondsController = CDate(My.Settings.AppCurTime).Second
        minutesController = CDate(My.Settings.AppCurTime).Minute
        hoursController = CDate(My.Settings.AppCurTime).Hour
        daysController = CDate(My.Settings.AppCurTime).Day
        monthsController = CDate(My.Settings.AppCurTime).Month
        yearsController = CDate(My.Settings.AppCurTime).Year

        SystemClockStartUp = True
        tmrAppTimeController.Start()

        LanguageInterpreter(My.Settings.ChosenLanguageIndex)

        ChefesToolStripMenuItem.Enabled = False
        ChefesToolStripMenuItem.Visible = False
        ReceitasToolStripMenuItem.Enabled = False
        ReceitasToolStripMenuItem.Visible = False
        AvaliaçõesToolStripMenuItem.Enabled = False
        AvaliaçõesToolStripMenuItem.Visible = False
        GestõesMassivasToolStripMenuItem.Enabled = False
        GestõesMassivasToolStripMenuItem.Visible = False
        ToolStripSeparator5.Visible = False
        AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Enabled = False
        AlterarDadosDaContaDeUtilizadorToolStripMenuItem.Visible = False
        SuporteTécnicoToolStripMenuItem.Enabled = False
        SuporteTécnicoToolStripMenuItem.Visible = False
        AdministraçãoToolStripMenuItem.Enabled = False
        AdministraçãoToolStripMenuItem.Visible = False
    Catch ex As Exception
        'exception handling code ...
    End Try
End Sub

Body:
Thanks to TnTinMn, the answer lied in simply instantiating the main form on the Ghost Form, while declaring the variable as public shared variable.
Then all that was required was to call the menustripitems through that variable.

Code for load event of Ghost Form:

Public Class fGhostForm

    Public Shared MainForm As fMainForm

    Private Sub fGhostForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Close()
    End Sub

    Private Sub fGhostForm_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        If My.Settings.FirstRun Then
            Dim FormToLaunch As fFirstRunApplicationSettings = New fFirstRunApplicationSettings()
            FormToLaunch.ShowDialog()
        Else
            MainForm = New fMainForm()
            MainForm.ShowDialog()
        End If
    End Sub
End Class

Code to call and control the menustripitems:

fGhostForm.MainForm.ChefesToolStripMenuItem.Enabled = True
fGhostForm.MainForm.ChefesToolStripMenuItem.Visible = True

Thanks everyone for their time.


来源: stackexchange

问:
How to replace a word after some specific tags in linux
I am in a situation where I need to replace some specific word after a match is found.
The condition is the tag should start with "detailSelection", after that wherever there is WORD1, I need to replace it with WORD2.

This is a small snippet from a big file, I have to do it in hundreds of file.

```<code>                         "detailSelection": {
                                        "name": "Alarm Detail",
                                        "type": "form-operation",
                                        "requireSelection": true,
                                        "dataSelection": {
                                            "typeSelection": {
                                                "domain": "ossm",
                                                "package": "WORD1",
                                                "type": "WORD1"
                                            },
</code>```

OUTPUT Should be like:

```<code>                   "detailSelection": {
                                        "name": "Alarm Detail",
                                        "type": "form-operation",
                                        "requireSelection": true,
                                        "dataSelection": {
                                            "typeSelection": {
                                                "domain": "ossm",
                                                "package": "WORD2",
                                                "type": "WORD2"
                                            },
</code>```

答:
Its very simple, you need to use sed command </p>

```<code>sed -i 's/WORD1/WORD2/g' filename.txt
</code>```

<p>-i will do this replace inside the file. In other words, it will alter the file. If you want to create a new file, then</p>

```<code>sed 's/WORD1/WORD2/g' filename.txt > newfile.txt
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am in a situation where I need to replace some specific word after a match is found.
The condition is the tag should start with "detailSelection", after that wherever there is WORD1, I need to replace it with WORD2.

This is a small snippet from a big file, I have to do it in hundreds of file.

                         "detailSelection": {
                                        "name": "Alarm Detail",
                                        "type": "form-operation",
                                        "requireSelection": true,
                                        "dataSelection": {
                                            "typeSelection": {
                                                "domain": "ossm",
                                                "package": "WORD1",
                                                "type": "WORD1"
                                            },

OUTPUT Should be like:

                   "detailSelection": {
                                        "name": "Alarm Detail",
                                        "type": "form-operation",
                                        "requireSelection": true,
                                        "dataSelection": {
                                            "typeSelection": {
                                                "domain": "ossm",
                                                "package": "WORD2",
                                                "type": "WORD2"
                                            },

Body:
Its very simple, you need to use sed command

sed -i 's/WORD1/WORD2/g' filename.txt

-i will do this replace inside the file. In other words, it will alter the file. If you want to create a new file, then

sed 's/WORD1/WORD2/g' filename.txt > newfile.txt


问:
How to simply combine flow files in nifi?
Let's say I have 100 flow files produced by one processor, each of them contains a different line. I want to get a new flow file which contains 100 line. How can I did that?

I have tried MergeContent processor, but it gives me the origin 100 flow files back.

Current config:

Update:

I debugged the output of MergeContent, in the first step JOIN, it seems ok since the data is 576.34 KB which contains 100 line. But the second step ATTRIBUTES_MODIFIED it seems only output 1 line to the final result.

Update:

This is my whole procedure.

Get from kafka one by one.

Convert kafka message to one line string in one flow file.

Merge multiple flow files into one.

PutHDFS.

Now I'm stuck at step 3, I can not merge them one by one. I don't care the order or the attribute, I just need limit the number.

Update:

I have try to set  correlation attribute to ${kafka.topic} since all the flow files from the same kafka topic, but they still can not merge:

答: Are you using the original or merged relationships from the MergeContent processor? The former will provide the same 100 flowfiles back to you in case you need to do additional processing; the latter will give you a single flowfile with the contents of all the merged flowfiles. It looks from your provenance listing that the merge event is happening successfully, so double check with relationships you are using. If possible, please post a screenshot of your flow.


问:
git - error: addinfo_cache failed for path 'file'
When I try to merge any branch in git into master I get error: addinfo_cache failed for path 'file'.

What I do:

```<code>>git checkout master
>git merge other-branch
</code>```

Git gives me:

```<code>error: addinfo_cache failed for path 'file'
file: unmerged (581c47f7d0e1a0bc825d528d9783ac18ee0cce27)
file: unmerged (26a0c24dccd2bc2f74e20488ca01bba2fcd9cf56)
file: unmerged (3be471ca5c689693339827a455f187814677642f)
fatal: git write-tree failed to write a tree
</code>```

>git status yields:

```<code>On branch master
Your branch is up-to-date with 'origin/master'.
Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:   file

no changes added to commit (use "git add" and/or "git commit -a")
</code>```

I have no idea what to do and can't find anython on the problem.

答:
I've recently encountered this error using 2.18.0.windows.1 git version when cherry-picking. The affected file wasn't even connected with the changes. Tried all the answers in this thread, tried disabling fscache and upgrading git to 2.21. Finally managed to resolve the issue by:

Removing the affected file

Resetting the state with git reset --hard origin/master (this did not work without step 1)

ContentLicense: CC BY-SA 3.0

Body:
When I try to merge any branch in git into master I get error: addinfo_cache failed for path 'file'.

What I do:

>git checkout master
>git merge other-branch

Git gives me:

error: addinfo_cache failed for path 'file'
file: unmerged (581c47f7d0e1a0bc825d528d9783ac18ee0cce27)
file: unmerged (26a0c24dccd2bc2f74e20488ca01bba2fcd9cf56)
file: unmerged (3be471ca5c689693339827a455f187814677642f)
fatal: git write-tree failed to write a tree

>git status yields:

On branch master
Your branch is up-to-date with 'origin/master'.
Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:   file

no changes added to commit (use "git add" and/or "git commit -a")

I have no idea what to do and can't find anython on the problem.


问:
When to register a method that will call Form.Invoke to an event?
I get the following exception in a Windows Form application

System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.

The method where the exception occurs calls this.Invoke (System.Windows.Forms.Form.Invoke). This method is registered to the event of another class in the constructor, which seems to lead to a race condition and this exception.

```<code>public Form1()
{
    InitializeComponent();
    SomeOtherClass.Instance.MyEvent += new SomeDelegate(MyMethod);
}

private void MyMethod()
{
    this.Invoke((MethodInvoker)delegate
    {
        // ... some code ...
    }
}
</code>```

At which stage of the form lifecycle is the Handle created? In which event of the form would it be safe to register the method to the foreign event?

答:
As everyone mentioned already IsHandleCreated is the way to go.
Following snippet tells how to do that.

```<code>public class TestEvent : Form
{

    protected override void OnHandleCreated(EventArgs e)
    {
        base.OnHandleCreated(e);
        MyMethod();

    }
    private void MyMethod()
    {

        this.Invoke(new Action(() =>
                                   {
                                      //Here goes your code.
                                   }));
    }
}
</code>```

Body:
I get the following exception in a Windows Form application

System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created.

The method where the exception occurs calls this.Invoke (System.Windows.Forms.Form.Invoke). This method is registered to the event of another class in the constructor, which seems to lead to a race condition and this exception.

public Form1()
{
    InitializeComponent();
    SomeOtherClass.Instance.MyEvent += new SomeDelegate(MyMethod);
}

private void MyMethod()
{
    this.Invoke((MethodInvoker)delegate
    {
        // ... some code ...
    }
}

At which stage of the form lifecycle is the Handle created? In which event of the form would it be safe to register the method to the foreign event?

Body:
As everyone mentioned already IsHandleCreated is the way to go.
Following snippet tells how to do that.

public class TestEvent : Form
{

    protected override void OnHandleCreated(EventArgs e)
    {
        base.OnHandleCreated(e);
        MyMethod();

    }
    private void MyMethod()
    {

        this.Invoke(new Action(() =>
                                   {
                                      //Here goes your code.
                                   }));
    }
}


问:
How do you see if a key includes a value and return the key up 2 levels? Alexa/JS
I want to see if a category is in a pack, and if it is, return that pack name.

So if my string was 'Pack1category1', I want to return 'pack1'.

How could I go about doing this?

```<code>{
    "paidTier": {
        "categoryPacks": {
            "pack1": {
                "categories": [
                    "Pack1category1",
                    "Pack1category2",
                    "Pack1category3",
                    "Pack1category4",
                    "Pack1category5",
                    "Pack1category6"
                ]
            },
            "pack2": {
                "categories": [
                    "Pack2category1",
                    "Pack2category2",
                    "Pack2category3",
                    "Pack2category4",
                    "Pack2category5",
                    "Pack2category6"
                ]
            }
        }
    }
}
</code>```

Something like this:

```<code>var string = 'Pack1category1'
//Loop through paidTier and find string
return 'pack1';
</code>```

or

```<code>var string = 'Pack2category5'
//Loop through paidTier and find string
return 'pack2';
</code>```

I've been at this for at least 10 hours and every method I've tried has failed. Please help! lol

答:
Since you mentioned you where using a for loop to traverse the object, I give you an approach using that way. We going to use for ... in to traverse the paidTier.cateroryPacks object and Array.includes() to check if the inner categories array includes the searched string.

const data = {"paidTier":{"categoryPacks":{"pack1":{"categories":["Pack1category1","Pack1category2","Pack1category3","Pack1category4","Pack1category5","Pack1category6"]},"pack2":{"categories":["Pack2category1","Pack2category2","Pack2category3","Pack2category4","Pack2category5","Pack2category6"]}}}};

function getPack(catPacks, str)
{
    for (const pack in catPacks)
    {
        if (catPacks[pack].categories.includes(str))
            return pack;
    }

    return "No Pack Found!";
}

let catPacks = data.paidTier.categoryPacks;
console.log("Result for Pack1category1:", getPack(catPacks, "Pack1category1"));
console.log("Result for Pack2category5:", getPack(catPacks, "Pack2category5"));
console.log("Result for Pack3category5:", getPack(catPacks, "Pack3category5"));```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console {background-color:black !important; color:lime;}
.as-console-wrapper {max-height:100% !important; top:0;}</code>```

Body:
I want to see if a category is in a pack, and if it is, return that pack name.

So if my string was 'Pack1category1', I want to return 'pack1'.

How could I go about doing this?

{
    "paidTier": {
        "categoryPacks": {
            "pack1": {
                "categories": [
                    "Pack1category1",
                    "Pack1category2",
                    "Pack1category3",
                    "Pack1category4",
                    "Pack1category5",
                    "Pack1category6"
                ]
            },
            "pack2": {
                "categories": [
                    "Pack2category1",
                    "Pack2category2",
                    "Pack2category3",
                    "Pack2category4",
                    "Pack2category5",
                    "Pack2category6"
                ]
            }
        }
    }
}

Something like this:

var string = 'Pack1category1'
//Loop through paidTier and find string
return 'pack1';

or

var string = 'Pack2category5'
//Loop through paidTier and find string
return 'pack2';

I've been at this for at least 10 hours and every method I've tried has failed. Please help! lol

Body:
Since you mentioned you where using a for loop to traverse the object, I give you an approach using that way. We going to use for ... in to traverse the paidTier.cateroryPacks object and Array.includes() to check if the inner categories array includes the searched string.

const data = {"paidTier":{"categoryPacks":{"pack1":{"categories":["Pack1category1","Pack1category2","Pack1category3","Pack1category4","Pack1category5","Pack1category6"]},"pack2":{"categories":["Pack2category1","Pack2category2","Pack2category3","Pack2category4","Pack2category5","Pack2category6"]}}}};

function getPack(catPacks, str)
{
    for (const pack in catPacks)
    {
        if (catPacks[pack].categories.includes(str))
            return pack;
    }

    return "No Pack Found!";
}

let catPacks = data.paidTier.categoryPacks;
console.log("Result for Pack1category1:", getPack(catPacks, "Pack1category1"));
console.log("Result for Pack2category5:", getPack(catPacks, "Pack2category5"));
console.log("Result for Pack3category5:", getPack(catPacks, "Pack3category5"));

.as-console {background-color:black !important; color:lime;}
.as-console-wrapper {max-height:100% !important; top:0;}


问:
How to add 3rd party JARs to Maven project
My area of expertise is not Java. I develop in other languages on other platforms.

Right now I'm developing a series of Java servlets for a project. The servlets are to run on a CentOS server running FileNetP8.

I actually got all of the planned items finished and running.

Now when I am trying to add a few more services, the library I came across is available via Maven. I have no idea what Maven is. Read up on it today. Created a test project to try it out.

My development environment is Eclipse Photon on Windows 10.

Now my problem is I can't figure out how to add the Filenet JARs to the project. I can't upload them to some Maven repo. Searching the Web says to add them to the local repo, but I don't understand how to do that to the Local repo in Eclipse's builtin Maven.

I think that the JARs don't need to be packaged within the deployment WAR because the app will be deployed to the Websphere server that runs Filenet so they should be available on it. Should I add them as external JAR references to get the project to compile?

答:
If the jars are available in Maven Central repo then all you hvae to do is add dependency under dependencies section in your pom.xml file. Set the scope as required, like you said jars don't needed to be packaged in WAR file as they might be available on server then you can set scope to provided.

```<code><dependency>
  <groupId>groud-id</groupId>
  <artifactId>artifact-id</artifactId>
  <version>version-numbe</version>
  <scope>scope</scope>
</dependency>
</code>```

If jars are not available in central repo and you want to install them on your local repo then below command should help you. More information here.

```<code>mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
</code>```

Body:
If the jars are available in Maven Central repo then all you hvae to do is add dependency under dependencies section in your pom.xml file. Set the scope as required, like you said jars don't needed to be packaged in WAR file as they might be available on server then you can set scope to provided.

<dependency>
  <groupId>groud-id</groupId>
  <artifactId>artifact-id</artifactId>
  <version>version-numbe</version>
  <scope>scope</scope>
</dependency>

If jars are not available in central repo and you want to install them on your local repo then below command should help you. More information here.

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>


问:
Did the MATLAB R2019a mxArray header change?
I have MATLAB mex code that hacks into the mxArray header to read and modify fields such as the CrossLink pointer (used for shared data copies) etc.  This is necessary to allow me to work with very large variables inside mex routines without creating deep copies. This code works well up to R2018b but now crashes MATLAB. What has changed?</p>

答:
The mxArray header has changed in R2019a. The location of the CrossLink field in the mxArray header has moved next to the reverse CrossLink field. So, the order for R2018b and earlier is this:

```<code>void *RevCrossLink;
mxClassID ClassID;
int VariableType;
mxArray *CrossLink;
    :
etc.
</code>```

but for R2019a it is this

```<code>void *RevCrossLink;
mxArray *CrossLink;  <-- moved
mxClassID ClassID;
int VariableType;
    :
etc.
</code>```

So if you want your code to be robust and compile/run under different MATLAB versions, you will need to programmatically determine the MATLAB version. C code to determine the MATLAB version at compile and run time can be found here:

https://www.mathworks.com/matlabcentral/fileexchange/67016-c-mex-matlab-version

Body:
The mxArray header has changed in R2019a. The location of the CrossLink field in the mxArray header has moved next to the reverse CrossLink field. So, the order for R2018b and earlier is this:

void *RevCrossLink;
mxClassID ClassID;
int VariableType;
mxArray *CrossLink;
    :
etc.

but for R2019a it is this

void *RevCrossLink;
mxArray *CrossLink;  <-- moved
mxClassID ClassID;
int VariableType;
    :
etc.

So if you want your code to be robust and compile/run under different MATLAB versions, you will need to programmatically determine the MATLAB version. C code to determine the MATLAB version at compile and run time can be found here:

https://www.mathworks.com/matlabcentral/fileexchange/67016-c-mex-matlab-version


问:
SQL Server INSERT INTO using transaction
I am using SQL Server. I have a stored procedure that does the following:

```<code>INSERT INTO Tbl1
    SELECT col1, col2, col3
    FROM Tbl2
</code>```

My question is: does this need a transaction with commit? From looking online it does not seem so. I will have it as part of a nightly batch process so want to make sure it behaves properly. Should I do a try catch in this case?

答: If you have just only this statement it doesn't matter, because implicitly it is a transaction. In case of failure it won't insert any rows, but in other case it will commit the changes. You might have a scenario when at the beggining of your procedure you delete rows and then inserting rows into a table. In such scenario it might be good to wrap it up in one transaction. Thanks to this when delete succeedes, but insert fails you will still have data in your table.

Body:
I am using SQL Server. I have a stored procedure that does the following:

INSERT INTO Tbl1
    SELECT col1, col2, col3
    FROM Tbl2

My question is: does this need a transaction with commit? From looking online it does not seem so. I will have it as part of a nightly batch process so want to make sure it behaves properly. Should I do a try catch in this case?


问:
SQL query to get count of unique combinations in the table - MySql
I have a mapping table like below

```<code>c1  c2
--  --
1   1
1   1
1   2
1   3
1   3
2   1
2   2
2   3
3   1
</code>```

and so on. The table has a separate id column (not showed here).
Here is my query so far :

```<code>SELECT `c1`, `c2`, COUNT(*) AS `count_of_uniques` FROM `map_table`
GROUP BY `c1`, `c2`
</code>```

I have also tried with distinct query like this.

```<code>SELECT `c1`, `c2`, COUNT(DISTINCT `c1`, `c2`) AS `count_of_uniques` FROM `map_table`
</code>```

The expected result is

```<code>c1  c2  count_of_uniques
--  --  ----------------
1   1   2
1   2   2
1   3   3
2   2   1
2   3   1
</code>```

My current query shows the correct output when the combination is made of two similar numbers, but when we have something like 1-2 and 2-1, the query does not have the correct output.

distinct shows still fewer results.

Any help is greatly appreciated. Thank you.

答:
You can use the functions least() and greatest() to get the pairs on which you will group:

```<code>select
  least(c1, c2) c1,
  greatest(c1, c2) c2,
  count(*) count_of_uniques
from map_table
group by
  least(c1, c2),
  greatest(c1, c2)
</code>```

See the demo.

Results:

```<code>| c1  | c2  | count_of_uniques |
| --- | --- | ---------------- |
| 1   | 1   | 2                |
| 1   | 2   | 2                |
| 1   | 3   | 3                |
| 2   | 2   | 1                |
| 2   | 3   | 1                |
</code>```

Body:
I have a mapping table like below

c1  c2
--  --
1   1
1   1
1   2
1   3
1   3
2   1
2   2
2   3
3   1

and so on. The table has a separate id column (not showed here).
Here is my query so far :

SELECT `c1`, `c2`, COUNT(*) AS `count_of_uniques` FROM `map_table`
GROUP BY `c1`, `c2`

I have also tried with distinct query like this.

SELECT `c1`, `c2`, COUNT(DISTINCT `c1`, `c2`) AS `count_of_uniques` FROM `map_table`

The expected result is

c1  c2  count_of_uniques
--  --  ----------------
1   1   2
1   2   2
1   3   3
2   2   1
2   3   1

My current query shows the correct output when the combination is made of two similar numbers, but when we have something like 1-2 and 2-1, the query does not have the correct output.

distinct shows still fewer results.

Any help is greatly appreciated. Thank you.

Body:
You can use the functions least() and greatest() to get the pairs on which you will group:

select
  least(c1, c2) c1,
  greatest(c1, c2) c2,
  count(*) count_of_uniques
from map_table
group by
  least(c1, c2),
  greatest(c1, c2)

See the demo.

Results:

| c1  | c2  | count_of_uniques |
| --- | --- | ---------------- |
| 1   | 1   | 2                |
| 1   | 2   | 2                |
| 1   | 3   | 3                |
| 2   | 2   | 1                |
| 2   | 3   | 1                |


问:
Filter products by category with AJAX problem with displaying products
I have problem with displaying products from category with ajax.
I've rendered all categories and all products on page and my categories are links and I prevented default action on links and I want to achieve this. When you click on the link of the category, that triggers ajax and show bellow products from that category, everything happens on same page without reload. But all I got is "no post found" when i click on category link</p>

```<code>function ajax_filter_get_posts( $taxonomy ) {

    // Verify nonce
    if( !isset( $_POST['afp_nonce'] ) || !wp_verify_nonce( $_POST['afp_nonce'], 'afp_nonce' ) )
      die('Permission denied');

    $taxonomy = $_POST['taxonomy'];

    // WP Query
    $args = array(
      'tag' => $taxonomy,
      'post_type' => 'product',
      'posts_per_page' => 10

    );

    if( !$taxonomy ) {
      unset( $args['tag'] );
    }

    $query = new WP_Query( $args );

    if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();

      $output  = '<h2><a href="'.get_permalink().'">'. get_the_title().'</a></h2>';
      $output .= get_the_excerpt();

      $result = 'success';

    endwhile; else:
      $output = '<h2>No posts found</h2>';
      $result = 'fail';

    endif;

    $response = json_encode($output);
    echo $response;

    die();
  }

  add_action('wp_ajax_filter_posts', 'ajax_filter_get_posts');
  add_action('wp_ajax_nopriv_filter_posts', 'ajax_filter_get_posts');
</code>```

```<code><article>
<?php
/**
 * Template name: AJAX Post Filter by Taxonomy
 *
 */
get_header();
$args = array(
    'post_type' => 'product',
    'posts_per_page' => 10
);

$query = new WP_Query( $args );

$tax = 'product_cat';
$terms = get_terms( $tax );
$count = count( $terms );

if ( $count > 0 ): ?>
    <div class="post-tags">
    <?php
        echo '<div class="container">';
        echo '<div class="row">';
        foreach ( $terms as $term ) {
         $term_link = get_term_link( $term, $tax );

         echo '<div class="col-4">';
        echo '<a href="' . $term_link . '" class="tax-filter" title="' . $term->slug . '">' . $term->name . '</a> ';
        echo '</div>';

     }
     echo '</div>';
        echo '</div>';
     ?>
    </div>
<?php endif;

if ( $query->have_posts() ): ?>
<div class="tagged-posts">
    <?php while ( $query->have_posts() ) : $query->the_post(); ?>

    <h2><a class="<?php echo $term->name; ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>

    <?php endwhile; ?>
</div>

<?php else: ?>
    <div class="tagged-posts">
        <h2>No posts found</h2>
    </div>
<?php endif;  ?>

</article>
<?php
get_footer();
</code>```

```<code>jQuery(document).ready(function( $ ) {
    $('.tax-filter').click( function(event) {

        if (event.preventDefault) {
            event.preventDefault();
        } else {
            event.returnValue = false;
        }

        var selecetd_taxonomy = $(this).attr('title');

        $('.tagged-posts').fadeOut();

        data = {
            action: 'filter_posts',
            afp_nonce: afp_vars.afp_nonce,
            taxonomy: selecetd_taxonomy,
        };

        $.ajax({
            type: 'product',
            dataType: 'json',
            url: afp_vars.afp_ajax_url,
            data: data,
            success: function( data, textStatus, XMLHttpRequest ) {
                $('.tagged-posts').html( data );
                $('.tagged-posts').fadeIn();
                console.log( textStatus );
                console.log( XMLHttpRequest );
            },
            error: function( MLHttpRequest, textStatus, errorThrown ) {
                console.log( MLHttpRequest );
                console.log( textStatus );
                console.log( errorThrown );
                $('.tagged-posts').html( 'No posts found' );
                $('.tagged-posts').fadeIn();
            }
        })

    });
});
</code>```

答:
In your query args you are filtering by tag whereas the taxonomy term that you're passing in is actually a product_cat.

Try changing your query arguments in ajax_filter_get_posts to the following:

```<code>$args = array(
  'post_type' => 'product',
  'posts_per_page' => 10
  'tax_query' => array(
    array (
      'taxonomy' => 'product_cat',
      'field' => 'slug',
      'terms' => $taxonomy,
    )
  ),
);
</code>```

Body:
I have problem with displaying products from category with ajax.
I've rendered all categories and all products on page and my categories are links and I prevented default action on links and I want to achieve this. When you click on the link of the category, that triggers ajax and show bellow products from that category, everything happens on same page without reload. But all I got is "no post found" when i click on category link

function ajax_filter_get_posts( $taxonomy ) {

    // Verify nonce
    if( !isset( $_POST['afp_nonce'] ) || !wp_verify_nonce( $_POST['afp_nonce'], 'afp_nonce' ) )
      die('Permission denied');

    $taxonomy = $_POST['taxonomy'];

    // WP Query
    $args = array(
      'tag' => $taxonomy,
      'post_type' => 'product',
      'posts_per_page' => 10

    );

    if( !$taxonomy ) {
      unset( $args['tag'] );
    }

    $query = new WP_Query( $args );

    if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();

      $output  = '
'. get_the_title().'
';
      $output .= get_the_excerpt();

      $result = 'success';

    endwhile; else:
      $output = '
No posts found
';
      $result = 'fail';

    endif;

    $response = json_encode($output);
    echo $response;

    die();
  }

  add_action('wp_ajax_filter_posts', 'ajax_filter_get_posts');
  add_action('wp_ajax_nopriv_filter_posts', 'ajax_filter_get_posts');

<?php
/**
 * Template name: AJAX Post Filter by Taxonomy
 *
 */
get_header();
$args = array(
    'post_type' => 'product',
    'posts_per_page' => 10
);

$query = new WP_Query( $args );

$tax = 'product_cat';
$terms = get_terms( $tax );
$count = count( $terms );

if ( $count > 0 ): ?>

    <?php
        echo '
';
        echo '
';
        foreach ( $terms as $term ) {
         $term_link = get_term_link( $term, $tax );

         echo '
';
        echo 'slug . '">' . $term->name . ' ';
        echo '
';

     }
     echo '
';
        echo '
';
     ?>

<?php endif;

if ( $query->have_posts() ): ?>

    <?php while ( $query->have_posts() ) : $query->the_post(); ?>

<a class="<?php echo $term->name; ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?>

    <?php the_excerpt(); ?>

    <?php endwhile; ?>

<?php else: ?>

No posts found

<?php endif;  ?>

<?php
get_footer();

jQuery(document).ready(function( $ ) {
    $('.tax-filter').click( function(event) {

        if (event.preventDefault) {
            event.preventDefault();
        } else {
            event.returnValue = false;
        }

        var selecetd_taxonomy = $(this).attr('title');

        $('.tagged-posts').fadeOut();

        data = {
            action: 'filter_posts',
            afp_nonce: afp_vars.afp_nonce,
            taxonomy: selecetd_taxonomy,
        };

        $.ajax({
            type: 'product',
            dataType: 'json',
            url: afp_vars.afp_ajax_url,
            data: data,
            success: function( data, textStatus, XMLHttpRequest ) {
                $('.tagged-posts').html( data );
                $('.tagged-posts').fadeIn();
                console.log( textStatus );
                console.log( XMLHttpRequest );
            },
            error: function( MLHttpRequest, textStatus, errorThrown ) {
                console.log( MLHttpRequest );
                console.log( textStatus );
                console.log( errorThrown );
                $('.tagged-posts').html( 'No posts found' );
                $('.tagged-posts').fadeIn();
            }
        })

    });
});

Body:
In your query args you are filtering by tag whereas the taxonomy term that you're passing in is actually a product_cat.

Try changing your query arguments in ajax_filter_get_posts to the following:

$args = array(
  'post_type' => 'product',
  'posts_per_page' => 10
  'tax_query' => array(
    array (
      'taxonomy' => 'product_cat',
      'field' => 'slug',
      'terms' => $taxonomy,
    )
  ),
);


问:
Accessing the state of a function at exit time (stop)
Let the following function:

tmp <- function(x){
      y <- 10
      stop('foo')
    }
```

<p>In reality, it's a function I don't have control of; I can't change its code.</p>

<p>How do I get to know the value of <code>y</code> as defined in the function when <code>stop</code> is invoked, programmatically?</p>

<p>Interactively, I can do the following:</p>

<pre class="lang-r prettyprint-override"><code>options(error = quote(dump.frames("testdump", FALSE)))
tmp()
v <- get("y", testdump[[1]])
options(error = NULL)
</code>```

I do get an error but can still get to the value of y thanks to dump.frames.

I've been reading http://adv-r.had.co.nz/Exceptions-Debugging.html but I must have missed a trick because I can't make that work programmatically.

Thanks!

答:
If you run the following code all at once (so not line by line), it will give you what you desire

```<code>tmp <- function(x){
  y <- 10
  stop('foo')
}
x= 1
debug(tmp)
tmp(x)
n
n
v <<- y
n
</code>```

Let me explain what happened. debug(tmp) makes R starts an interactive debug session as soon as tmp(x) is called.

This is just a hack in our case to get into the function environment. In the interactive situation, n will make the cursor go to the next line. We need to go two lines down before we get to the line where y is defined.

After y = 10 is run in the function, we can assign y to our global environment. This is what the operator <<- does. It assigns the variable y in the function environment to the variable v in the global environment.

Then I choose to exit the interactive session by executing stop("foo"), but you could also do something else here to step out of the function environment, that is up to you.

If you want to see what is happening you could just execute this line by line too.

Body:
Let the following function:

tmp <- function(x){
      y <- 10
      stop('foo')
    }

In reality, it's a function I don't have control of; I can't change its code.

How do I get to know the value of y as defined in the function when stop is invoked, programmatically?

Interactively, I can do the following:

options(error = quote(dump.frames("testdump", FALSE)))
tmp()
v <- get("y", testdump[[1]])
options(error = NULL)

I do get an error but can still get to the value of y thanks to dump.frames.

I've been reading http://adv-r.had.co.nz/Exceptions-Debugging.html but I must have missed a trick because I can't make that work programmatically.

Thanks!

Body:
If you run the following code all at once (so not line by line), it will give you what you desire

tmp <- function(x){
  y <- 10
  stop('foo')
}
x= 1
debug(tmp)
tmp(x)
n
n
v <<- y
n

Let me explain what happened. debug(tmp) makes R starts an interactive debug session as soon as tmp(x) is called.

This is just a hack in our case to get into the function environment. In the interactive situation, n will make the cursor go to the next line. We need to go two lines down before we get to the line where y is defined.

After y = 10 is run in the function, we can assign y to our global environment. This is what the operator <<- does. It assigns the variable y in the function environment to the variable v in the global environment.

Then I choose to exit the interactive session by executing stop("foo"), but you could also do something else here to step out of the function environment, that is up to you.

If you want to see what is happening you could just execute this line by line too.


问:
How can I iterate over each data label of each series
I have a chart where I want to display only some datalabels on the charts. I iterated on series.points but I am not able to get the present datalabel value.

Even when I use number_format="0.0%", all the datalabels value becomes multiplied by 100.

```<code>            for point in series.points:
                print(dir(point.data_label))
</code>```

The output should exact datalabel of that point instead of multiplied by 100 value and point datalabel value less than 2 should be hidden.

答:
Data-label values are not available directly as they are not actually written to the PPTX file. Luckily, they are easy to calculate for yourself.

If you want to change the data labels selectively, you'll need to replace ones you don't want to show with a blank string ("").

Chart values are available on chart.series[i].values:

```<code>for series in chart.series:
    print(series.values)
</code>```

A series is a set of bars all the same color, so you might need to rearrange these values for your particular use.

The percentage format type is meant to be applied to proportion values, like turn 0.5 into 50%. So if you want to use that format, you need to make sure your chart values are in that form. If you just want to append a "%" character, use "0.0\%" (note the backslash).

Body:
I have a chart where I want to display only some datalabels on the charts. I iterated on series.points but I am not able to get the present datalabel value.

Even when I use number_format="0.0%", all the datalabels value becomes multiplied by 100.

            for point in series.points:
                print(dir(point.data_label))

The output should exact datalabel of that point instead of multiplied by 100 value and point datalabel value less than 2 should be hidden.

Body:
Data-label values are not available directly as they are not actually written to the PPTX file. Luckily, they are easy to calculate for yourself.

If you want to change the data labels selectively, you'll need to replace ones you don't want to show with a blank string ("").

Chart values are available on chart.series[i].values:

for series in chart.series:
    print(series.values)

A series is a set of bars all the same color, so you might need to rearrange these values for your particular use.

The percentage format type is meant to be applied to proportion values, like turn 0.5 into 50%. So if you want to use that format, you need to make sure your chart values are in that form. If you just want to append a "%" character, use "0.0\%" (note the backslash).


问:
How to install ipa file (no jailbreak)
I uploaded this ipa file on the website https://www.diawi.com/
I tried to install on the phone but it respond "Ongame could not be installed at this time."
I tried to sign again but still failed.
Please guide me to edit this ipa file so I can install it on my iphone.
Link file: http://ongame.tk/file/Ongame240.ipa
image http://ongame.tk/file/err.jpg</p>

答:
I have used this website https://www.diawi.com/ to share ipa file.

To share your app ipa file via this website you have to follow these steps:

First add devices(iPhone where you will try to install your app) UDID to your Apple developer account.

Then add these devices into your app Development Provisioning Profiles.

Now generate and download these profiles.

Use these profiles to create Development ipa file.

Upload this ipa to https://www.diawi.com/ and share the genearted link with those people whose device UDID you have added in Provisioning profile.

Note: Person who is trying to install may have to trust your provisioning profile in his/her device.

You can also checkout Diawi knowledge base Can't install an app on a device? Things to check

I hope this will solve your problem.

Title: How to install ipa file (no jailbreak)


问:
Trying to save timeStamp recorded in jmeter results from csv to MSSQL server
I am not able to save proper timeStamp from JMeter to CSV and same CSV to MSSQL server.

I am saving results right now but they appear in a wierd manner like 1559087654 etc

I want proper format of the timeStamp at what time and date exact results were recorded.

答:
You have to update jmeter.properties file which is present in /bin folder of jmeter location.

Please go through the below screenshot and uncomment the line selected in the screenshot. (Its uncommented in the screenshot)