.net – Reference a .net 3.5 assembly in a Script Task in SSIS 2005

.net-2.0.net-3.5ssis

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.

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

  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;
          }
       }  
    }
    
  2. Gave it a Strong Name key
  3. Added the assembly to the GAC using gacutil
  4. Copied the assembly to the C:\Windows\Microsoft.NET\Framework\v2.0.50727 folder…dev
    machine is running Windows 7
  5. Created a Script Task and added a reference to the assembly
  6. In the Script Task

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

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"

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?

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…

Best Answer

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.

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.

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).

Related Topic