如何修复Biml内置SSIS脚本任务的失败任务:不支持此类接口

数据Rob

我一直在测试通过Biml for SSIS包创建脚本任务。我希望能够在本地成功执行/测试软件包。

我无法从本地开发环境中执行项目的程序包,因为它们全部出错,并且下面出现相同的错误。

问题: Error: 0x0 at ScriptTask 1, Script Task : 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 '{2CD38B23-6C17-4025-A8B6-D2E497DD1DDC}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index) at ScriptMain.Main() Error: 0x6 at ScriptTask 1: The script returned a failure result. Task failed: ScriptTask 1

在将项目从Visual Studio部署到该服务器上的SSIS目录(SSISDB)(SQL Server 2016)之后,我能够从另一台服务器成功执行这些程序包。

我对AssemblyInfo和ScriptMain使用了以下引用:

  • 差异文档代码示例:https ://www.varigence.com/Documentation/Samples/Biml/Script+Task+Project
  • BimlScript代码示例:http ://bimlscript.com/Snippet/Details/74
<Script ProjectCoreName="ST_232fecafb70a4e8a904cc21f8870eed0" Name="ScriptTask 1">
    <ScriptTaskProject>
        <ScriptTaskProject ProjectCoreName="ST_c41ad4bf47544c49ad46f4440163feae" Name="TaskScriptProject1">
            <AssemblyReferences>
                <AssemblyReference AssemblyPath="Microsoft.SqlServer.ManagedDTS.dll" />
                <AssemblyReference AssemblyPath="Microsoft.SqlServer.ScriptTask.dll" />
                <AssemblyReference AssemblyPath="System.dll" />
                <AssemblyReference AssemblyPath="System.AddIn.dll" />
                <AssemblyReference AssemblyPath="System.Data.dll" />
                <AssemblyReference AssemblyPath="System.Windows.Forms.dll" />
                <AssemblyReference AssemblyPath="System.Xml.dll" />
            </AssemblyReferences>
            <Files>
                <File Path="AssemblyInfo.cs">
                    using System.Reflection;
                    using System.Runtime.CompilerServices;

                    //
                    // General Information about an assembly is controlled through the following
                    // set of attributes. Change these attribute values to modify the information
                    // associated with an assembly.
                    //
                    [assembly: AssemblyTitle("ST_c41ad4bf47544c49ad46f4440163feae.csproj")]
                    [assembly: AssemblyDescription("")]
                    [assembly: AssemblyConfiguration("")]
                    [assembly: AssemblyCompany("Varigence")]
                    [assembly: AssemblyProduct("ST_c41ad4bf47544c49ad46f4440163feae.csproj")]
                    [assembly: AssemblyCopyright("Copyright @ Varigence 2013")]
                    [assembly: AssemblyTrademark("")]
                    [assembly: AssemblyCulture("")]
                    //
                    // Version information for an assembly consists of the following four values:
                    //
                    //      Major Version
                    //      Minor Version
                    //      Build Number
                    //      Revision
                    //
                    // You can specify all the values or you can default the Revision and Build Numbers
                    // by using the '*' as shown below:

                    [assembly: AssemblyVersion("1.0.*")]
                </File>
                <File Path="ScriptMain.cs">
                    using System;
                    using System.Data;
                    using Microsoft.SqlServer.Dts.Runtime;
                    using System.Windows.Forms;

                    // if SSIS2012, use the following line:
                    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]

                    // if earlier version, use the next line instead of the above line:
                    // [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
                    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
                    {
                        enum ScriptResults
                        {
                            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
                        };

                        public void Main()
                        {
                            try
                            {
                                int totalInsertedRowsToDestination = (int)Dts.Variables["User::TotalInsertedRowsToDestination"].Value;
                                int rowCountNew = (int)Dts.Variables["User::RowCountNew"].Value;
                                int totalUpdatedRowsToDestination = (int)Dts.Variables["User::TotalUpdatedRowsToDestination"].Value;
                                int rowCountChanged = (int)Dts.Variables["User::RowCountChanged"].Value;
                                int totalUnChangedRowsToDestination = (int)Dts.Variables["User::TotalUnChangedRowsToDestination"].Value;
                                int rowCountUnchanged = (int)Dts.Variables["User::RowCountUnchanged"].Value;

                                totalInsertedRowsToDestination += rowCountNew;
                                totalUpdatedRowsToDestination += rowCountChanged;
                                totalUnChangedRowsToDestination += rowCountUnchanged;

                                Dts.Variables["User::TotalInsertedRowsToDestination"].Value = totalInsertedRowsToDestination;
                                Dts.Variables["User::TotalUpdatedRowsToDestination"].Value = totalUpdatedRowsToDestination;
                                Dts.Variables["User::TotalUnChangedRowsToDestination"].Value = totalUnChangedRowsToDestination;

                                Dts.TaskResult = (int)ScriptResults.Success;
                            }
                            catch (Exception ex)
                            {
                                Dts.Events.FireError(0, "Script Task ", ex.Message + "\r" + ex.StackTrace, String.Empty, 0);
                                Dts.TaskResult = (int)ScriptResults.Failure;
                            }
                        }                                   
                    }
                </File>
            </Files>
            <ReadOnlyVariables>
                <Variable Namespace="User" DataType="Int32" VariableName="RowCountNew" />
                <Variable Namespace="User" DataType="Int32" VariableName="RowCountChanged" />
                <Variable Namespace="User" DataType="Int32" VariableName="RowCountUnchanged" />
            </ReadOnlyVariables>
            <ReadWriteVariables>
                <Variable Namespace="User" DataType="Int32" VariableName="TotalInsertedRowsToDestination" />
                <Variable Namespace="User" DataType="Int32" VariableName="TotalUpdatedRowsToDestination" />
                <Variable Namespace="User" DataType="Int32" VariableName="TotalUnChangedRowsToDestination" />
            </ReadWriteVariables>
        </ScriptTaskProject>
    </ScriptTaskProject>
    <PrecedenceConstraints>
        <Inputs>
          <Input OutputPathName="SQL Update <#=dstTableName#>.Output" />
        </Inputs>
    </PrecedenceConstraints>
</Script>

我希望输出为:SSIS package finished: Success脚本任务中没有错误。

我的环境:

  • Windows 10 Enterprise 6.3 x64
  • Microsoft Visual Studio 2015 Shell (integrated): 14.0.23107.0
  • Microsoft .NET Framework: 4.7.03056
  • BimlExpress: 1.0
  • SQL Server Data Tools: 14.0.61705.170
  • SQL Server 2016 (SP1-GDR): 13.0.4224.16(x64)
数据Rob

我在多个不同的环境/机器上本地复制了该错误,并确定了解决方法。

解决方案:将SSIS项目的TargetServerVersion更改SQL Server 2014SQL Server 2016得到的运行程序包后的消息是SSIS package finished: Success

为什么:

这些环境中的某些内容缺少与IDTSVa​​riables100接口相关的SQL Server 2014的TargetServerVersion所需的工作片段。该接口与SQL Server .NET SDK 2017 2016有关.https: //docs.microsoft.com/zh-cn/dotnet/api/microsoft.sqlserver.dts.runtime.wrapper.idtsvariables100 view = sqlserver-2017

关于TargetServerVersion和ProjectVersion,Andy Leonard在他的博客文章中解释说,

“只要当前生产版本为SSIS 2012 +,TargetServerVersion属性即可用于使用最新工具来维护SSIS项目的当前生产版本。只需更改以下内容,即可将TargetServerVersion属性更新为可用的最新版本:下拉菜单中的值”https://andyleonard.blog/2018/08/a-tale-of-two-properties-ssis-projectversion-and-targetserverversion/

<ProductVersion>14.0.600.250</ProductVersion>

更多想法请参见“ SSDT其他参考”部分。

如何:

  1. 右键单击Visual Studio中的SSIS项目[MySsisProject(SQL Server 2014)],然后选择“属性”。

选择SSIS项目的属性

  1. 在新打开的“属性页”中,展开“配置属性”组,然后选择“常规”。然后选择适当的TargetServerVersion(在我的情况下为SQL Server 2016)

选择TargetServerVersion

  1. 阅读警告,提及扩展可能存在的问题,并确定是否要继续。

TargetServerVersion更改警告

现在,SSIS项目在项目名称后面的括号中带有SQL Server 2016 MySsisProject (SQL Server 2016)这样可以解决问题。接下来,在本地执行软件包以验证软件包是否成功完成。

经过测试的环境/机器:

  1. 环境 :

    • Windows 10 Enterprise 6.3 x64
    • Microsoft Visual Studio 2015 Shell (integrated): 14.0.23107.0
    • Microsoft .NET Framework: 4.7.03056
    • BimlExpress: 1.0
    • SQL Server Data Tools: 14.0.61705.170
    • SQL Server 2016 (SP1-GDR): 13.0.4224.16(x64)
  2. 环境 :

    • Windows 10 Enterprise 6.3 x64
    • Microsoft Visual Studio Enterprise 2017: 15.9.8
    • Microsoft .NET Framework: 4.7.03056
    • BimlExpress: 1.0
    • SQL Server Data Tools: 15.1.61902.21100
    • SQL Server 2016 (SP1-GDR): 13.0.4224.16(x64)
  3. 环境 :

    • Windows Server 2012 R2 Datacenter 6.3 x64
    • Microsoft Visual Studio Professional 2015: 14.0.25431.01 Update 3
    • Microsoft .NET Framework: 4.7.02053
    • BimlExpress: 1.0
    • SQL Server Data Tools: 14.0.61705.170
    • SQL Server 2016 (SP1): 13.0.4001.0(x64)

SSDT的其他参考(SQL Server数据工具):

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用BIML添加脚本任务

来自分类Dev

NewtonSoft.Json无法使SSIS脚本任务失败

来自分类Dev

如何通过SSIS脚本任务打开OLEDBConnection?

来自分类Dev

如何在ssis脚本任务中显示变量

来自分类Dev

如何在脚本任务中访问对象 SSIS 变量?

来自分类常见问题

在SSIS中保护脚本任务

来自分类Dev

在SSIS中保护脚本任务

来自分类Dev

SSIS脚本任务区域设置

来自分类Dev

SSIS脚本任务Web服务错误

来自分类Dev

SSIS 脚本任务 - VB 循环问题

来自分类Dev

SSIS平面文件存在-没有文件时脚本任务失败

来自分类Dev

如何使BIML编译器在脚本任务,脚本组件中允许c#6语言功能

来自分类Dev

如何在SSIS C#脚本任务中添加Microsoft Office Interop

来自分类Dev

如何在SSIS脚本任务中传递自定义对象列表?

来自分类Dev

如何在SSIS C#脚本任务中添加Microsoft Office Interop

来自分类Dev

SSIS脚本任务找不到对程序集的引用

来自分类Dev

SSIS脚本任务int32变量比较

来自分类Dev

SSIS:将记录集写入文件的脚本任务

来自分类Dev

SSIS脚本任务使用通配符删除文件

来自分类Dev

SSIS脚本任务参考dll以编程方式

来自分类Dev

使用脚本任务的SSIS调用Java服务

来自分类Dev

SSIS脚本任务从Excel工作表中删除行

来自分类Dev

SSIS中的脚本任务不起作用

来自分类Dev

SSIS:将记录集写入文件的脚本任务

来自分类Dev

影响C#脚本任务中的SSIS对象变量

来自分类Dev

SSIS 脚本任务(计划时不工作)

来自分类Dev

对“此类不支持SAAJ 1.3”的修复不起作用

来自分类Dev

ClickOnce – Redemption.dll-不支持此类接口

来自分类常见问题

Jenkinsfile任务失败[不支持的类文件主要版本57]

Related 相关文章

热门标签

归档