如何修复 Biml 构建的 SSIS 脚本任务的失败任务:不支持此类接口
How to fix a Failed Task for a Biml-Built SSIS Script Task: No such interface supported
我一直在测试通过 Biml 为 SSIS 包创建脚本任务。
我希望能够在本地 execute/test 成功打包。
我无法从我的本地开发环境执行项目的包,因为它们都出现以下相同的错误。
问题:
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 到该服务器(SQL Server 2016)上的 SSIS 目录 (SSISDB) 进行项目部署后,我能够从另一台服务器成功执行这些包。
我对 AssemblyInfo 和 ScriptMain 使用了以下引用:
- Varigence 文档代码示例:
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)
我在多个不同的 environments/machines 上本地重现了该错误并找到了修复方法。
解决方案: 将 SSIS 项目的 TargetServerVersion 从 SQL Server 2014
更改为 SQL Server 2016
。
在 运行 包之后的 结果 消息是 SSIS package finished: Success
.
为什么:
这些环境中缺少与 IDTSVariables100 接口相关的 SQL Server 2014 TargetServerVersion 工作所需的部分。该接口与 SQL Server .NET SDK 2017 2016 有关。
https://docs.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.dts.runtime.wrapper.idtsvariables100?view=sqlserver-2017
关于 TargetServerVersion 和 ProjectVersion,Andy Leonard 在他的博客 post 中进行了解释,
"the TargetServerVersion property can be used to maintain the current Production version of an SSIS project using the latest tools, as long as the current Production version is SSIS 2012+. And the TargetServerVersion property can be updated to the latest version available by simply changing the value in a dropdown".
https://andyleonard.blog/2018/08/a-tale-of-two-properties-ssis-projectversion-and-targetserverversion/
<ProductVersion>14.0.600.250</ProductVersion>
下面 SSDT 的其他参考资料 部分有更多想法。
操作方法:
- 在 Visual Studio 和 select 属性中右键单击 SSIS 项目 [MySsisProject (SQL Server 2014)]。
- 在新打开的 属性 页面中,展开配置属性组和 select 常规。然后 select 适当的 TargetServerVersion(SQL Server 2016 在我的情况下)
- 阅读警告,提及扩展可能存在的问题并确定是否要继续。
现在 SSIS 项目在项目名称 MySsisProject (SQL Server 2016)
后的括号中包含 SQL Server 2016。这解决了这个问题。
接下来,在本地执行包以验证包是否成功完成。
测试Environments/Machines:
环境:
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)
环境:
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)
环境:
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 服务器数据工具):
- SSDT 被设计为向后兼容和安装 SSDT 的信息:https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-2017
- 脚本任务失败示例,然后 SSDT 版本(15.9.0 绑定到 VS 2017)修复了问题:
https://feedback.azure.com/forums/908035-sql-server/suggestions/32896399-script-tasks-losing-code-in-ssdt-17-1-for-visual-s
https://docs.microsoft.com/en-us/sql/ssdt/release-notes-ssdt?view=sql-server-2017#ssdt-for-visual-studio-2017-1570
- 我发现了一个与 "SSIS Script Task - No Interface Supported" 相关的类似问题,涉及版本差异,修复了加载旧版本;然而,答案是有限的,并没有描述为上述问题确定的问题所需的解决方案:
在我们决定删除不同的路径后,我们也遇到了一些环境问题。
因为有些人在 GAC 中有一个 dll,而其他人只在 Visual Studio PublicAssemblies 目录
中
我们仍然想删除路径,但仍需要提供有关目标版本的提示。
我们现在在 Biml 中修复它,像这样进行程序集引用:
<AssemblyReference AssemblyPath="Microsoft.SqlServer.DTSRuntimeWrap, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=x86, Custom=null" />
并使其更容易被其他 dll 重用:
<# int MajorSQLVersion = 13; #>
<AssemblyReference AssemblyPath="Microsoft.SqlServer.DTSRuntimeWrap, Version=<#= MajorSQLVersion.ToString() #>.0.0.0" />
我一直在测试通过 Biml 为 SSIS 包创建脚本任务。 我希望能够在本地 execute/test 成功打包。
我无法从我的本地开发环境执行项目的包,因为它们都出现以下相同的错误。
问题:
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 到该服务器(SQL Server 2016)上的 SSIS 目录 (SSISDB) 进行项目部署后,我能够从另一台服务器成功执行这些包。
我对 AssemblyInfo 和 ScriptMain 使用了以下引用:
- Varigence 文档代码示例:
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)
我在多个不同的 environments/machines 上本地重现了该错误并找到了修复方法。
解决方案: 将 SSIS 项目的 TargetServerVersion 从 SQL Server 2014
更改为 SQL Server 2016
。
在 运行 包之后的 结果 消息是 SSIS package finished: Success
.
为什么:
这些环境中缺少与 IDTSVariables100 接口相关的 SQL Server 2014 TargetServerVersion 工作所需的部分。该接口与 SQL Server .NET SDK 2017 2016 有关。 https://docs.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.dts.runtime.wrapper.idtsvariables100?view=sqlserver-2017
关于 TargetServerVersion 和 ProjectVersion,Andy Leonard 在他的博客 post 中进行了解释,"the TargetServerVersion property can be used to maintain the current Production version of an SSIS project using the latest tools, as long as the current Production version is SSIS 2012+. And the TargetServerVersion property can be updated to the latest version available by simply changing the value in a dropdown". https://andyleonard.blog/2018/08/a-tale-of-two-properties-ssis-projectversion-and-targetserverversion/
<ProductVersion>14.0.600.250</ProductVersion>
下面 SSDT 的其他参考资料 部分有更多想法。
操作方法:
- 在 Visual Studio 和 select 属性中右键单击 SSIS 项目 [MySsisProject (SQL Server 2014)]。
- 在新打开的 属性 页面中,展开配置属性组和 select 常规。然后 select 适当的 TargetServerVersion(SQL Server 2016 在我的情况下)
- 阅读警告,提及扩展可能存在的问题并确定是否要继续。
现在 SSIS 项目在项目名称 MySsisProject (SQL Server 2016)
后的括号中包含 SQL Server 2016。这解决了这个问题。
接下来,在本地执行包以验证包是否成功完成。
测试Environments/Machines:
环境:
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)
环境:
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)
环境:
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 服务器数据工具):
- SSDT 被设计为向后兼容和安装 SSDT 的信息:https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-2017
- 脚本任务失败示例,然后 SSDT 版本(15.9.0 绑定到 VS 2017)修复了问题: https://feedback.azure.com/forums/908035-sql-server/suggestions/32896399-script-tasks-losing-code-in-ssdt-17-1-for-visual-s https://docs.microsoft.com/en-us/sql/ssdt/release-notes-ssdt?view=sql-server-2017#ssdt-for-visual-studio-2017-1570
- 我发现了一个与 "SSIS Script Task - No Interface Supported" 相关的类似问题,涉及版本差异,修复了加载旧版本;然而,答案是有限的,并没有描述为上述问题确定的问题所需的解决方案:
在我们决定删除不同的路径后,我们也遇到了一些环境问题。 因为有些人在 GAC 中有一个 dll,而其他人只在 Visual Studio PublicAssemblies 目录
中我们仍然想删除路径,但仍需要提供有关目标版本的提示。
我们现在在 Biml 中修复它,像这样进行程序集引用:
<AssemblyReference AssemblyPath="Microsoft.SqlServer.DTSRuntimeWrap, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=x86, Custom=null" />
并使其更容易被其他 dll 重用:
<# int MajorSQLVersion = 13; #>
<AssemblyReference AssemblyPath="Microsoft.SqlServer.DTSRuntimeWrap, Version=<#= MajorSQLVersion.ToString() #>.0.0.0" />