SSIS脚本任务-不支持接口 [英] SSIS Script Task - No Interface Supported

查看:209
本文介绍了SSIS脚本任务-不支持接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目的:我有一个带有各种程序包的SSIS解决方案,由于这些表具有不同的结构,因此目前创建了一组这些程序包,每个表都有一个程序包.目的是创建一个模板包(完成),更新变量/表名(完成),重新初始化和重新映射列,为每个表执行包.

问题:因此,正如您所知道的,我已经到了需要重新初始化的地步,但是我无法执行数据流任务并不断出现此错误:

No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))

当我运行此代码时:

    //// Get Data Flow task 
    TaskHost tHost = pkgOut.Executables[0] as TaskHost;
    MainPipe dataFlowTask = (MainPipe)tHost.InnerObject;

我正在使用的代码如下:

    public void Main()
    {
        // Set Project Variables
        List<string> pkgVars = new List<string>
        {
            @"pPR_SSIS_Catalog_Server",
            @"pPR_SSIS_Catalog_Project",
            @"pPR_SSIS_Catalog_Folder"
        };

        // Get Package
        String pkgLocation = @"C:\PATH\TO\TEMPLATE\PACKAGE\a_Load_SAP_Template.dtsx";
        Application app = new Application();
        Package pkgIn = app.LoadPackage(pkgLocation, null);
        String pkgName = "DynamicPackage";

        // Add Connections (cos they're project connections and aren't stored in package)
        ConnectionEnumerator allConns = Dts.Connections.GetEnumerator();
        while ((allConns.MoveNext()) && (allConns.Current != null))
            pkgIn.Connections.Join(allConns.Current);

        // Convert new package to XML so we can cheat and just do a find and replace
        XmlDocument pkgXML = new XmlDocument();
        pkgIn.SaveToXML(ref pkgXML, null, null);

        // Replace strings
            // Set SAP table
            String pkgStr = pkgXML.OuterXml.ToString();
            pkgStr = pkgStr.Replace("#SAP_SRC_TABLE#", "MyF-ingSAPTables"); // Replace SAP Table Name

            // Set Project Variables references == values  -- REMEMBER TO CHECK FOR INT PARAMS zzz
            foreach (string var in pkgVars)
                pkgStr = pkgStr.Replace(@"@[$Project::" + var + @"]", @"""" + Convert.ToString(Dts.Variables[var].Value) + @"""");

        // Convert back to XML
        XmlDocument newXML = new XmlDocument();
        newXML.LoadXml(pkgStr);
        Package pkgOut = new Package();
        pkgOut.LoadFromXML(newXML, null);

        //// Get Data Flow task 
        TaskHost tHost = pkgOut.Executables[0] as TaskHost;
        MainPipe dataFlowTask = (MainPipe)tHost.InnerObject; // THIS IS WHERE THE CODE ERRORS

        new Application().SaveToXml(String.Format(@"D:\PATH\TO\SAVE\LOCATION\{0}.dtsx", pkgName), pkgOut, null);

        Dts.TaskResult = (int)ScriptResults.Success;

    }

我尝试过:

  • 删除数据流以外的所有内容
  • 重新创建空白数据流
  • 重新创建软件包
  • 在脚本中制作了一个程序包并创建了数据流(此方法有效,但是当我打开程序包时,数据流没有出现...可能添加了错误,但在运行TaskHost部分时可以看到它)

我不确定我还能尝试什么,我已经看到可能需要重新注册一些.dll的信息,但是我没有管理员权限,所以我不希望遇到麻烦的地方不知道是否行得通.

任何帮助将不胜感激.

谢谢

解决方案

已修复,是由于正在加载的.DLL版本不同.加载了旧版本,一切顺利.

Purpose: I have an SSIS Solution with various packages, one set of these packages is currently created with a package per table due to them having different structures. The aim is to create a template package (done), update variables/table names (done), reinitialise and re-map columns, execute package for each table.

Problem: So, as you can tell, I'm up to the point that i need to reinitialise but I am unable to get to the data flow task and keep getting this error:

No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))

When I run this code:

    //// Get Data Flow task 
    TaskHost tHost = pkgOut.Executables[0] as TaskHost;
    MainPipe dataFlowTask = (MainPipe)tHost.InnerObject;

The code that I am using is below:

    public void Main()
    {
        // Set Project Variables
        List<string> pkgVars = new List<string>
        {
            @"pPR_SSIS_Catalog_Server",
            @"pPR_SSIS_Catalog_Project",
            @"pPR_SSIS_Catalog_Folder"
        };

        // Get Package
        String pkgLocation = @"C:\PATH\TO\TEMPLATE\PACKAGE\a_Load_SAP_Template.dtsx";
        Application app = new Application();
        Package pkgIn = app.LoadPackage(pkgLocation, null);
        String pkgName = "DynamicPackage";

        // Add Connections (cos they're project connections and aren't stored in package)
        ConnectionEnumerator allConns = Dts.Connections.GetEnumerator();
        while ((allConns.MoveNext()) && (allConns.Current != null))
            pkgIn.Connections.Join(allConns.Current);

        // Convert new package to XML so we can cheat and just do a find and replace
        XmlDocument pkgXML = new XmlDocument();
        pkgIn.SaveToXML(ref pkgXML, null, null);

        // Replace strings
            // Set SAP table
            String pkgStr = pkgXML.OuterXml.ToString();
            pkgStr = pkgStr.Replace("#SAP_SRC_TABLE#", "MyF-ingSAPTables"); // Replace SAP Table Name

            // Set Project Variables references == values  -- REMEMBER TO CHECK FOR INT PARAMS zzz
            foreach (string var in pkgVars)
                pkgStr = pkgStr.Replace(@"@[$Project::" + var + @"]", @"""" + Convert.ToString(Dts.Variables[var].Value) + @"""");

        // Convert back to XML
        XmlDocument newXML = new XmlDocument();
        newXML.LoadXml(pkgStr);
        Package pkgOut = new Package();
        pkgOut.LoadFromXML(newXML, null);

        //// Get Data Flow task 
        TaskHost tHost = pkgOut.Executables[0] as TaskHost;
        MainPipe dataFlowTask = (MainPipe)tHost.InnerObject; // THIS IS WHERE THE CODE ERRORS

        new Application().SaveToXml(String.Format(@"D:\PATH\TO\SAVE\LOCATION\{0}.dtsx", pkgName), pkgOut, null);

        Dts.TaskResult = (int)ScriptResults.Success;

    }

I have tried:

  • Removing everything but the data flow
  • Recreated a blank data flow
  • Recreated the package
  • Made a package in the script and created the data flow (this works but when i open the package, the data flow does not appear...might have added it wrong but it can see it when I run the TaskHost section)

I am not sure what else I can try, I have seen information that I might need to re-register some .dlls but I do not have admin access and I'd prefer not to go through the hassle for something where I do not know whether it will work.

Any help would be appreciated.

Thanks,

解决方案

Fixed, was due to version difference in the .DLL that was being loaded. Loaded an older version and all went through fine.

这篇关于SSIS脚本任务-不支持接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆