2013-07-18 96 views
0

當我運行我的包時,我得到了一個有效的問題。它在我的電腦上運行失敗,在其他任何人都成功。 該錯誤是由腳本組件(變爲紅色)引起的,它處於Post Execute階段,而不是在腳本組件的後執行,而是在包的運行時。錯誤是:SSIS腳本組件運​​行時錯誤

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)). 

enter image description here

我想,這個問題是有關的變量,因爲當我刪除所有相關變量的代碼,包成功運行。腳本組件中的代碼:

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(); 

} 

有沒有人遇到同樣的問題?任何人都可以告訴我什麼是POST執行階段嗎?謝謝

更多信息:我試圖重新安裝SQL Server,但這沒有幫助。並非所有帶有變量的腳本組件都在我的SSIS中運行失敗(不在與錯誤代碼相同的包中)

+0

那麼PostExecute中導致數據流失敗的代碼是什麼? – billinkc

+0

該問題說:Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVa​​riables100.Unlock() at Microsoft.SqlServer.Dts.Pipeline.ScriptComponent.UnlockReadOnlyVariables() at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PostExecute() ); – morgan117

+0

但是我的PostExecute中沒有任何代碼,好像是在後臺。 – morgan117

回答

0

SSIS中的所有任務/容器具有相同的生命週期。你可以通過觀看Event Handlers火來看到其中的一些。在數據流任務內部的腳本組件中,將採取各種步驟。其中一部分就是驗證(這個合同說我應該從這個表中獲得一個整數類型的列 - 我可以連接,它是否存在,是否是正確的類型等)。

確認後,任務將設置並拆除要執行的步驟。由於您似乎在腳本中使用了SSIS變量,因此將部分前/後執行時間用於允許將變量(SSIS)轉換爲變量(.net)並返回。

直到我看到PostExecute方法中導致失敗的特定代碼時,我無法說明代碼問題可能是什麼。

我無法重現您的問題。雖然這是Integration Services的2012版本,但您使用它的腳本組件的行爲將相同。我沒有將我的輸出發送到Excel,但考慮到它是失敗的腳本,這並不重要。

data flow task

我的腳本組件。在編輯我的代碼之前,我在菜單中選擇了我的Variable,User :: Count550作爲ReadOnly變量。

public class ScriptMain : UserComponent 
{ 
    private int scheduled550; 

    public override void PreExecute() 
    { 
     base.PreExecute(); 
     this.scheduled550 = Variables.Count550; 
    } 

    public override void PostExecute() 
    { 
     base.PostExecute(); 
     //this.Variables.Count550 = scheduled550; 
     //this.VariableDispenser.LockForWrite("Count550"); 
    } 

    public override void Input0_ProcessInputRow(Input0Buffer Row) 
    { 
     if (true) 
     { 
      this.scheduled550++; 
     } 
    } 

} 
+1

我真的很感謝你的幫助,但正如我所說的,這個問題只出現在我的電腦中,不能在任何其他人的電腦中重現,所以你認爲有沒有可以影響這個的配置/註冊表? – morgan117