title: System.NullReferenceException in VB.NET
body: <p>I'm getting this error when trying to execute my code:</p>
  
  <pre><code>An unhandled exception of type 'System.NullReferenceException' occurred in [ApplicationName].exe
  Additional information: Object reference not set to an instance of an object.
  </code></pre>
  
  <p>This happens every time I trigger this action. This is the code:</p>
  
  <pre><code>Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Button1.Enabled = False
      Button1.Text = "Checking..."
      ToolStripStatusLabel1.Text = "Checking for devices..."
      Dim ADB_Check_Result As Boolean = False
      Dim Fastboot_Check_Result As Boolean = False
      Dim ADB_Devices As New Process()
      ADB_Devices.StartInfo.UseShellExecute = False
      ADB_Devices.StartInfo.RedirectStandardOutput = True
      ADB_Devices.StartInfo.CreateNoWindow = True
      ADB_Devices.StartInfo.FileName = "adb.exe"
      ADB_Devices.StartInfo.Arguments = "devices"
      ADB_Devices.Start()
      Dim ADB_Devices_Stream As IO.StreamReader = ADB_Devices.StandardOutput
      Dim ADB_Devices_Output As String
      While ADB_Devices_Stream.EndOfStream = False
          ADB_Devices_Output = ADB_Devices_Stream.ReadToEnd()
      End While
      ADB_Devices.WaitForExit()
      ADB_Devices.Close()
      If ADB_Devices_Output.Contains("  device") Then
          ToolStripStatusLabel1.Text = "Device found! [ADB]"
          Button1.Enabled = True
          ADB_Check_Result = True
          Fastboot_Check_Result = False
          Button1.Text = "Check for Devices"
      Else
          If ADB_Devices_Output.Contains("recovery") Then
              ToolStripStatusLabel1.Text = "Device found! [Recovery Mode]"
              Button1.Enabled = True
              ADB_Check_Result = True
              Fastboot_Check_Result = False
              Button1.Text = "Check for Devices"
          Else
              If ADB_Check_Result = False Then
                  Dim Fastboot_Devices As New Process()
                  Fastboot_Devices.StartInfo.UseShellExecute = False
                  Fastboot_Devices.StartInfo.RedirectStandardOutput = True
                  Fastboot_Devices.StartInfo.CreateNoWindow = True
                  Fastboot_Devices.StartInfo.FileName = "fastboot.exe"
                  Fastboot_Devices.StartInfo.Arguments = "devices"
                  Fastboot_Devices.Start()
                  Dim Fastboot_Devices_Stream As IO.StreamReader = Fastboot_Devices.StandardOutput
                  Dim Fastboot_Devices_Output As String
                  While Fastboot_Devices_Stream.EndOfStream = False
                      Fastboot_Devices_Output = Fastboot_Devices_Stream.ReadToEnd()
                  End While
                  Fastboot_Devices.WaitForExit()
                  Fastboot_Devices.Close()
                  If Fastboot_Devices_Output.Contains("fastboot") Then
                      ToolStripStatusLabel1.Text = "Device found! [Fastboot Mode]"
                      Button1.Enabled = True
                      ADB_Check_Result = False
                      Fastboot_Check_Result = True
                      Button1.Text = "Check for Devices"
                  End If
              End If
          End If
      End If
      If Fastboot_Check_Result = False + ADB_Check_Result = False Then
          ToolStripStatusLabel1.Text = "Device not found."
          Button1.Enabled = True
          ADB_Check_Result = False
          Fastboot_Check_Result = False
          Button1.Text = "Check for Devices"
      End If
  End Sub
  </code></pre>
  
  <p>And this line is highlighted:</p>
  
  <pre><code>If Fastboot_Devices_Output.Contains("fastboot") Then
  </code></pre>
  
  <p>I tried everything, but I don't know how to solve this problem :/</p>