title: Package hangs on Script Task C#
body: <p>Inside a For Loop container, I download a file with a script task and then with another script task I am checking the size of it. On Dev server when I execute it through SSDT, it executes with success. When I run it to the same server as a Job or adhoc execution it hangs( after downloading the 1st file). Both script tasks have try &amp; catch and the job executes through SQL server agent. The logging shows PreExecute for the ForLoop &amp; for the DownloadFile script task, the rest are Pre/post validations.Below the script. Any thoughts?</p>
  
  <pre><code>#region Namespaces
  using Microsoft.SqlServer.Dts.Runtime;
  using System;
  using System.Data;
  using System.IO;
  using System.Windows.Forms;
  #endregion
  
  namespace ST_7b3b944d502f476a871b7fa26cddac6e
  {
      [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
      public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
      {
  
          public void Main()
          {
              try{
              string file = Dts.Variables["User::v_Filename"].Value.ToString();
              string Path = Dts.Variables["$Project::p_path"].Value.ToString();
  
              FileInfo filesize = new FileInfo(file); 
              long size = filesize.Length; 
  
                  if (size &gt; 100) 
                      { Dts.Variables["User::EmptyFile"].Value = false; 
                      }
                       else 
                      {
                        Dts.Variables["User::EmptyFile"].Value = true; 
                      } 
                          }
                  catch (Exception ex)
                  {
                      throw ex;
                  }
          }
  
          #region ScriptResults declaration
          enum ScriptResults
          {
              Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
              Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
          };
          #endregion
  
      }
  }
  </code></pre>