0
Private client As IFirebaseClient
    
Public Class PersonalData
    Public Property helloBlock() As String = "off"
End Class
    
Private Sub helloToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles helloToolStripMenuItem.Click
    Try

        Dim PD As New PersonalData() With
                {
                .helloBlock = "off"
                }

        Dim save = client.Set("func/", PD) 'To save data to Firebase Database.

        MessageBox.Show("hello off", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Catch ex As Exception
        If ex.Message = "One or more errors occurred." Then
            MessageBox.Show("Cannot connect to firebase, check your network !", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Else
            MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Try
End Sub

in this line Dim save = client.Set("func/", PD) 'To save data to Firebase Database.

error System.NullReferenceException Object reference not set to an instance of an object.

can anyone here help me pls fix this.

dadadada
  • 5
  • 3
  • 1
    Seems like you didn’t create an instance of an `IFirebaseClient` implementation and assign it to `client` before this. – Ry- May 24 '22 at 22:46
  • can you write an answer pls for me? @Ry- ♦ – dadadada May 24 '22 at 23:42
  • 1
    Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – John May 25 '22 at 01:09

1 Answers1

0

It seems I forgot to initialize it in main_load:

Try
      client = New FireSharp.FirebaseClient(fcon)
  Catch ex As Exception
      MessageBox.Show(ex.Message)
End Try
Trevortni
  • 688
  • 8
  • 23
dadadada
  • 5
  • 3