SSIS 2008:在版本化的脚本任务/脚本组件中使用自定义 DLL

本文关键字:脚本 组件 DLL 自定义 任务 版本 SSIS 2008 | 更新日期: 2023-09-27 18:33:44

我有大约 ~100 个 SSIS 包,负责将数据从一个产品迁移到另一个产品。 这些包几乎总是包含至少一个脚本任务和/或脚本组件,这些脚本任务和/或脚本组件使用在 .NET 3.5 中生成且具有强名称的自定义 DLL。 每次我在包中引用它时,我们都会确保引用将属性"特定版本"设置为 false。在我将 SSIS 包部署到的环境中,DLL 已使用 gacutil 进行 GAC .exe并转储到 SQL Server 程序集缓存中。

我遇到的问题是我的自定义 DLL 的版本随着 TFS 的每次生成而增加。 从我所做的研究中,似乎引用"特定版本"属性没有影响。 由于我们使用 DLL 的 1.0.0.0 进行开发,因此它仍在寻找该版本。 我能够解决此问题的唯一方法是在 SSIS 包中打开需要它的每个脚本任务并简单地保存。 这不是一个可行的选择。 我还发现了一篇博客文章 (http://dougbert.com/blog/post/Recompile-VSTA-scripts-programmatically-in-SSIS.aspx(,它可以让我们自动执行此操作,但使用 100+ SSIS 包来执行此操作需要花费太多时间保存/更新我的所有 SSIS 包

注意:我还使用 C# API 执行 SSIS 包。

我在寻找什么:

  • 允许我们继续在 SSIS 脚本任务/脚本组件中使用版本控制 DLL 的任何解决方案
  • 如果在没有 SSIS 2012 的情况下修复此问题

以下是我收到的错误:

Error in Microsoft.SqlServer.Dts.Runtime.TaskHost/ : 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'CustomDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=119c04fbde27c5df' or one of its dependencies. The system cannot find the file specified.
File name: 'CustomDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=119c04fbde27c5df'
   at ST_240ac16d255540ce822401f59c67e591.csproj.ScriptMain.Method1()
   at ST_240ac16d255540ce822401f59c67e591.csproj.ScriptMain.Main()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM'Software'Microsoft'Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM'Software'Microsoft'Fusion!EnableLog].
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   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 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
   at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()</c

SSIS 2008:在版本化的脚本任务/脚本组件中使用自定义 DLL

特定版本不用于此目的。 您需要在配置文件中设置绑定策略,这将允许在运行时接受一个程序集版本号来代替另一个程序集版本号。 看看这个链接 - 它比我更好地解释了一切。