title: Why am I getting object reference not set error on script task connector?
body: <p>I have an SSIS package (SQL Server 2005) that loops through a bunch of flat files in a folder. I need to wait until the source application has finished writing the file before I can open it in my flat file import task.</p>
  
  <p>I have a For Each loop container and within it a script task to execute before the Data Flow Task.</p>
  
  <p>When I try to create the success connector between the Script Task and the Data Flow Task I get this error: </p>
  
  <blockquote>
    <p><em>Could not create connector. Object reference not set to an instance of
    an object.</em></p>
  </blockquote>
  
  <p>I get that something is being set to nothing, but I can't see it. I have <code>DelayValidation</code> set to true on both the Script Task and the Data Flow Task. What else am I missing?</p>
  
  <p>I'm a C# guy so maybe I'm missing something obvious in the VB. Here's the script I poached from the interwebs:</p>
  
  <pre><code>Public Sub Main()
      Dim strFileName As String = CType(Dts.Variables("FileName").Value, String)
      Dim objFS As System.IO.FileStream
      Dim bolFinished As Boolean = False
  
      Do
          Try
              objFS = System.IO.File.Open(strFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
              bolFinished = True
              objFS.Close()
          Catch ex As Exception
              System.Threading.Thread.Sleep(1000)
          End Try
      Loop
  
      If bolFinished Then
          Dts.TaskResult = Dts.Results.Success
      Else
          Dts.TaskResult = Dts.Results.Failure
      End If
  End Sub
  </code></pre>