2014-05-12 158 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