将包格式2008升级到2012后,SSIS脚本任务错误

时间:2014-05-12 23:38:57

标签: sql-server ssis

我有一个已升级到SQL Server 2012的SSIS包,并且在尝试运行简单的脚本任务时遇到运行时错误。

运行时错误提供的信息很少。

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

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题并且发现SSIS正在寻找我在脚本任务中引用但未找到它的DLL。出于某种原因,它只查看C:\ Program Files(x86)\ Microsoft SQL Server \ 110 \ DTS \ Binn文件夹。