【发布时间】:2011-01-05 03:49:00
【问题描述】:
我已经使用一个非常基本的示例(如下所述)来实现这一点,我想看看其他 SOers 是否有经验做我正在尝试的事情......在 SSIS 2005 的脚本任务中使用 3.5 框架程序集.
除了我在 Visual Studio 2008 中针对 3.5 框架之外,我基本上遵循了找到 here... 的页面。
-
编写/编译您的代码(针对 3.5 框架)只是一些简单的 Linq,以便我使用大于 2.0 的框架功能
using System; using System.Collections.Generic; using System.Text; using System.Linq; namespace Ext { public class Extend { public string GetValue () { /* Test Linq to "prove" that we're not running against the 2.0 framework. I know this code could be improved, but bear with me... it's throwaway code just to test the concept */ string [] teststring = new string [3]; teststring[0] = "named Extend"; string returnString = String.Empty; var s = teststring.Where(x => x.ToString() == "named Extend"); foreach (var x in s) { returnString = x.ToString(); } return "Extending Script Task through a custom library " + returnString; } } } - 给它一个强名称键
- 使用 gacutil 将程序集添加到 GAC
- 已将程序集复制到 C:\Windows\Microsoft.NET\Framework\v2.0.50727 文件夹...dev
机器正在运行 Windows 7 - 创建了脚本任务并添加了对程序集的引用
-
在脚本任务中
Dim x As New Extend() MsgBox(x.GetValue.ToString())
它工作正常,因为当我运行 SSIS 项目时,我会返回一个带有文本的消息框
"通过名为 Extend 的自定义库扩展脚本任务"
所以...我的问题是,当我尝试做更复杂的事情时,SSIS 项目/脚本任务是否仍然有效...尤其是当我调用使用 LinqToEntities 的(尚未编写的)程序集时?
我必须将文件复制到 Framework 2.0 文件夹并将其添加到 GAC 对我来说似乎很奇怪......但也许这只是一个奇怪的 SSIS 要求......我知道我不能在脚本任务,除非该程序集位于 Framework 2.0 文件夹中...
【问题讨论】: