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
- Create a signing key (See also, How to: Create a Public/Private Key Pair)
- Open Visual Studio 2008 command Prompt – the regular command prompt will not work
- Change to a friendly directory: cd %userprofile%\Desktop
- Create the key file: sn -k key.snk
- 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
- Right-click the Project
- Select “Properties”
- Navigate to the “Signing” tab
- Browse to strong name key file (which was created in the previous step)
- Recompile the project
- Copy the re-compiled assembly to your GAC
- gacutil -i “C:\Path\to\CustomAssemblyName.dll”
- Copy assembly to “%programfiles(x86)%\Microsoft SQL Server\100\SDK\Assemblies”
- Add reference in script task. Repeat this for every Script Task you want to access this assembly from
- Right-click References
- Click “Add Reference…”

Add Reference...
- On the .NET tab, scroll to find your assembly
- Press “OK”
- The Assembly should now appear under the References list
- Add a reference to the assembly in code, at the top
- (C#) Using CustomAssemblyName;
- (VB.NET) Imports CustomAssemblyName
- 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.