title: SSIS Script Component runtime error
body: <p>I got a valid issue when I run my package. It runs failed in my PC and success in anyone else.
  The error is caused by Script Component (turned red), and it is in Post Execute phase, not the post execute in the script componet, but in the runtime of package. The error is:</p>
  
  <pre><code>Information: 0x40043008 at Data Flow Task, SSIS.Pipeline: Post Execute phase is beginning.
  Error: 0xC0047062 at Data Flow Task, Script Component [263]: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables100'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{22992C1D-393D-48FB-9A9F-4E4C62441CCA}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Favjh.png" alt="enter image description here"></p>
  
  <p>I guess the issue is related to variables, because when I remove all the code related to variables, the package run successfully. The code in script component: </p>
  
  <pre><code>private int scheduled550;
  private int scheduled620;
  private int scheduled720;
  private int scheduled820;
  public override void PreExecute()
  {
  
      base.PreExecute();
      scheduled550 = Variables.Count550;
      scheduled620 = Variables.Count620;
      scheduled720 = Variables.Count720;
      scheduled820 = Variables.Count820;
  
  }
  
  public override void PostExecute()
  {
      base.PostExecute();
  
  }
  </code></pre>
  
  <p>Did anyone ever encounter the same issue? Can anyone tell me what will POST Execute phase do? Thanks</p>
  
  <p>More info: I have tried to re-install SQL Server, but this is not help. And not all the script component with variables failed running in my SSIS (not in the same package with the error one)</p>