title: SSIS script task is only working with debugging mode
body: <p>I am using VS 2017 and SQL server 2016 to do the job. I create a script task that tries to send email by using SendGrid. If I put a break point inside the script task, I won't have problem to execute my SSIS package and then get the email. However, if I simply execute the package, the entire package still can be executed successfully but I cannot get the email, which I suspect that script task does not get executed. The following is the code of my script task </p>
  
  <pre><code>    public void Main()
      {
          string User_Email = Dts.Variables["User::UserEmail"].Value.ToString();
          try
          {
              if (!File.Exists(Dts.Variables["User::OutputPath"].Value.ToString()))
                  throw new FileNotFoundException();
              File.Copy(Dts.Variables["User::OutputPath"].Value.ToString(), Dts.Variables["User::DestinationPath"].Value.ToString() + Dts.Variables["User::co_num"].Value.ToString() + ".pdf", true);
  
              AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
  
              SendGridMailHelper.SendOrderVerification(User_Email, "user name");
  
          }
          catch (FileNotFoundException)
          {
              MessageBox.Show("The file is not found in the specified location");
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
          Dts.TaskResult = (int)ScriptResults.Success;
      }
      static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
      {
          if (args.Name.Contains("SendGrid"))
          {
              string path = @"F:\DLL\";
              return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "SendGrid.dll"));
          }
          if (args.Name.Contains("System.Net.Http"))
          {
              string path = @"F:\DLL\";
              return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "System.Net.Http.dll"));
          }
          if (args.Name.Contains("Newtonsoft.Json"))
          {
              string path = @"F:\DLL\";
              return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Newtonsoft.Json.dll"));
          }
          return null;
      }
  </code></pre>
  
  <p>To be safe, I checked the windows log and it showed the run time error when I run  the package without adding check points. However, I cannot figure it out what it means. Any thoughts will be very helpful. Thank you.</p>
  
  <blockquote>
    <p>Application: DtsDebugHost.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.MissingMethodException
       at ST_b240be27e55248ea869be51aa06a2018.SendGridMailHelper+&lt;_SendEmail>d__7.MoveNext()
       at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[ST_b240be27e55248ea869be51aa06a2018.SendGridMailHelper+&lt;_SendEmail>d__7, ST_b240be27e55248ea869be51aa06a2018, Version=1.0.6877.42064, Culture=neutral, PublicKeyToken=null]](&lt;_SendEmail>d__7 ByRef)
       at ST_b240be27e55248ea869be51aa06a2018.SendGridMailHelper._SendEmail(System.Collections.Generic.List`1, System.Object, System.String)
       at ST_b240be27e55248ea869be51aa06a2018.SendGridMailHelper+d__9.MoveNext()
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()</p>
  </blockquote>