Accessing Custom .NET Assemblies in SSIS 2008 Script Tasks

In: SSIS


14 Oct 2009

If you need to access a custom .NET Assembly from an SSIS Script Task, Microsoft doesn’t make things very easy – but it’s still possible with a little setup. This is a great way to introduce custom data types or some new functionality without having to replicate that code in a new environment.

The Setup

  • Windows 7 64-bit
  • Visual Studio 2008
  • SQL Server 2008 64-bit

The Process

  1. Create a signing key (See also, How to: Create a Public/Private Key Pair)
    1. Open Visual Studio 2008 command Prompt – the regular command prompt will not work
    2. Change to a friendly directory: cd %userprofile%\Desktop
    3. Create the key file: sn -k key.snk
  2. Sign the assembly – There are a few ways to do this, but I found this to be the easiest. If you want to sign it some other way, check out How to: Sign an Assembly with a Strong Name
    1. Right-click the Project
    2. Select “Properties”
    3. Navigate to the “Signing” tab
    4. Browse to strong name key file (which was created in the previous step)
    5. Recompile the project
  3. Copy the re-compiled assembly to your GAC
    1. gacutil -i “C:\Path\to\CustomAssemblyName.dll”
  4. Copy assembly to “%programfiles(x86)%\Microsoft SQL Server\100\SDK\Assemblies”
  5. Add reference in script task. Repeat this for every Script Task you want to access this assembly from
    1. Right-click References
    2. Click “Add Reference…”

      Add Reference...

      Add Reference...

    3. On the .NET tab, scroll to find your assembly
    4. Press “OK”
    5. The Assembly should now appear under the References list
  6. Add a reference to the assembly in code, at the top
    1. (C#) Using CustomAssemblyName;
    2. (VB.NET) Imports CustomAssemblyName
  7. You should now have full access to the imported DLL

Caveats

This method works pretty well, but deployment isn’t exactly seamless – you’ll have to repeat this for each server and re-register & copy the DLL separately for any updates. Additionally, there is no way to globally add the assembly reference to the entire project or package. Instead, you’ll have to repeat step 6 (adding the reference) for every Script Task.

  • Share/Bookmark

Comment Form

  • Kurt Hitchen: A friend has let me "see" there calendar in Google Calendar, but because their calendar is set to pr [...]
  • bugoy8: https://www.google.com/calendar/dav/nba_13_%4cos+%41ngeles+%4cakers#sports@group.v.calendar.google.c [...]
  • Speaker: Wasn't able to understand how to access the shared folder in the quest OS from this tutorial. Hmmm [...]
  • Elena Kuznetsova: I have killed an hour to figure out how to sync Google contacts' birthday and I have this done! U [...]
  • Andy: I have been trying to figure this out forever.....Thank you ever so much!! [...]


This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.