2014-05-12 159 views
2

我有一個SSIS包已升級到SQL Server 2012,並且當它嘗試運行一個簡單的腳本任務時遇到運行時錯誤。SSIS腳本任務錯誤升級包形式2008年至2012年後

運行時錯誤提供的信息非常少。

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 
    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
    at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) 
    at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript() 

它似乎這是正確的情況發生時,它會嘗試,因爲我設置一個斷點右它進入main()和它甚至沒有到達那裏執行腳本。幾乎就像它找不到編譯的腳本或其他東西。

這是腳本代碼:這非常簡單。

/* 
    Microsoft SQL Server Integration Services Script Task 
    Write scripts using Microsoft Visual C# 2008. 
    The ScriptMain is the entry point class of the script. 
*/ 

using System; 
using System.Data; 
using Microsoft.SqlServer.Dts.Runtime; 
using System.Windows.Forms; 
using System.Xml; 
using System.Data.SqlClient; 
using System.Data.OleDb; 
using System.IO; 



namespace ST_645b1fbdfe504c9482df626a189b6659.csproj 
{ 
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute] 
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase 
    { 

     #region VSTA generated code 
     enum ScriptResults 
     { 
      Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success, 
      Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure 
     }; 
     #endregion 

     /* 
     The execution engine calls this method when the task executes. 
     To access the object model, use the Dts property. Connections, variables, events, 
     and logging features are available as members of the Dts property as shown in the following examples. 

     To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value; 
     To post a log entry, call Dts.Log("This is my log text", 999, null); 
     To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true); 

     To use the connections collection use something like the following: 
     ConnectionManager cm = Dts.Connections.Add("OLEDB"); 
     cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;"; 

     Before returning from this method, set the value of Dts.TaskResult to indicate success or failure. 

     To open Help, press F1. 
    */ 

     public void Main() 
     { 
      WriteError("Error_FactEFCTaps_StageTaps_TripKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_ActionKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_ServiceKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_ZoneKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_YardKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_MTTapDateKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_MTTapTimeKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_StopKeyEndDateNull1"); 
      WriteError("Error_FactEFCTaps_StageTaps_NoPlatformKey2"); 
      WriteError("Error_FactEFCTaps_StageTaps_RouteID0"); 
      WriteError("Error_FactEFCTaps_StageTaps_PlatformKey1"); 
      WriteError("Error_FactEFCTaps_StageTaps_NoPlatformKey3"); 
      WriteError("Error_FactEFCTaps_StageTaps_NoPlatformKey1"); 
      WriteError("Error_FactEFCTaps_StageTaps_NoPlatformKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_InstitutionKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_ProductKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_CardKey"); 
      WriteError("Error_FactEFCTaps_StageTaps_VehicleKeyTraxFR"); 


      Dts.TaskResult = (int)ScriptResults.Success; 
     } 

     public void WriteError(string variable) 
     { 
      //serialize to xml 
      OleDbDataAdapter da = new OleDbDataAdapter(); 
      DataTable dt = new DataTable(); 
      DataSet ds = new DataSet(); 

      da.Fill(dt, Dts.Variables[variable].Value); 
      ds.Tables.Add(dt); 
      string xml = ds.GetXml(); 

      if (xml != "<NewDataSet />") 
      { 
       //write to db 
       string ErrSource = Dts.Variables[variable].Name; 
       string BatchID = Dts.Variables["BatchID"].Value.ToString(); 
       SqlConnection cn = new SqlConnection(); 
       cn = (SqlConnection)(Dts.Connections["DW01_ADO"].AcquireConnection(Dts.Transaction) as SqlConnection); 
       SqlCommand cmd = new SqlCommand("insert dbo.EFC_ErrorRows_XML(ErrorSource,RowData,BatchID) values(@ErrorSource, @XML,@BatchID)", cn); 
       cmd.Parameters.Add("@ErrorSource", SqlDbType.VarChar).Value = ErrSource; 
       cmd.Parameters.Add("@XML", SqlDbType.Xml).Value = xml; 
       cmd.Parameters.Add("@BatchID", SqlDbType.Int).Value = BatchID; 
       cmd.ExecuteNonQuery(); 
      } 
     } 
    } 
} 
+0

我的猜測是它不喜歡命名空間出於某種原因。嘗試將腳本粘貼到轉換爲2012年後生成的新腳本任務中,然後查看結果如何。 –

+0

試過了。同樣的結果。 –

回答

0

我有同樣的問題,想通了,SSIS正在尋找一個DLL我的腳本任務中引用並沒有發現它。由於某些原因,它只能在C:\ Program Files(x86)\ Microsoft SQL Server \ 110 \ DTS \ Binn文件夾中查找。

+0

它應該在哪裏看?什麼是DLL? – Cid

+0

腳本任務屬性中是否存在引用路徑? – influent