引用一个.NET 3.5组件脚本任务在SSIS 2005? [英] Reference a .net 3.5 assembly in a Script Task in SSIS 2005?

查看:133
本文介绍了引用一个.NET 3.5组件脚本任务在SSIS 2005?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个使用非常简单的例子(如下所述)工作,我想看看是否有其他SOers有经验,做什么,我试图...在SSIS 2005采用了一块3.5框架组件脚本任务

I've got this to work using a very basic example(outlined below) and I want to see if other SOers have experience doing what I'm attempting...using a 3.5 framework assembly in a Script Task in SSIS 2005.

我已经基本沿袭了网页发现这里 ...除了我的目标3.5框架,同时在Visual Studio 2008。

I've basically followed the page found here... except I targeted the 3.5 framework while in Visual Studio 2008.

  1. 写/编译code(目标3.5框架),只是一些简单的LINQ让我用一个大于2.0框架功能

  1. Write/compile your code (targeted the 3.5 framework) Just some simple Linq so that I'm using a greater than 2.0 framework feature

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;
      }
   }  
}

  • 给了它一个强名称密钥
  • 添加装配到GAC使用GACUTIL
  • 复制的组件安装到C:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727文件夹...开发
    该机运行的是Windows 7
  • 创建一个脚本任务,并增加了一个参考组装
  • 在脚本任务

  • Gave it a Strong Name key
  • Added the assembly to the GAC using gacutil
  • Copied the assembly to the C:\Windows\Microsoft.NET\Framework\v2.0.50727 folder...dev
    machine is running Windows 7
  • Created a Script Task and added a reference to the assembly
  • In the Script Task

    Dim x As New Extend()
    MsgBox(x.GetValue.ToString())  
    

  • 它的工作原理确定,当我运行的SSIS项目因为我得到一个消息框与文本
     通过命名扩展自定义库扩展脚本任务

    It works OK cuz when I run the SSIS project I get back a message box with the text
    "Extending Script Task through a custom library named Extend"

    所以...我的问题是将在SSIS项目/脚本任务仍然当我尝试做更复杂的东西的工作......尤其是当我调用使用LinqToEntities我的(尚未被写入)组装?

    So...my question is will the SSIS project/Script Task still work when I try to do more sophisticated stuff...especially when I call my (yet to be written) assembly that uses LinqToEntities?

    我觉得奇怪,我说,我必须将文件复制到Framework 2.0的文件夹并将其添加到GAC ...但也许这只是一个奇怪的SSIS的要求......我知道我不能添加引用脚本任务,除非该组件是在Framework 2.0中文件夹...

    It seems strange to me that I have to copy the file to the Framework 2.0 folder AND add it to the GAC...but maybe it's just a weird SSIS requirement...I know I can't add the reference in the Script Task unless that assembly's in the Framework 2.0 folder...

    推荐答案

    哇,我知道这个答案是来晚了。但我认为它不会产生任何问题,因为SSIS将加载程序集从GAC运行时,只要你有.NET Framework 2.0和3.5的机器上,在code会在运行时工作。

    wow, i know this answer is coming late. but i think it does not create any problems because SSIS will load the assembly at runtime from GAC, as long as you have .net framework 2.0 AND 3.5 on the machine, the code will work at runtime.

    在Framework 2.0中文件仅用于开发IDE和precompile的脚本任务/组件。运行过程中,所有重要的是,如果在GAC中的版本存在。

    The file in framework 2.0 is only used for development ide and to precompile the script task/component. during runtime, all that matters is if the version exists in GAC.

    如果你没有precompile你的任务,那么你需要的DLL在两个地方,框架2.0文件夹,GAC,因为SSIS将首先编译脚本任务(所以它需要的参考框架2.0文件夹中)然后运行的任务(参考值将来自GAC加载)。

    If you did not precompile your tasks, then you will need the dll in two places, the framework 2.0 folder AND GAC, because SSIS will compile the script task first (so it needs the reference in framework 2.0 folder) and then run the task (reference will be loaded from GAC).

    这篇关于引用一个.NET 3.5组件脚本任务在SSIS 2005?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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