Software Development
Blogs and Discussion
developer.*
Books Articles Blogs Subscribe d.* Gear About Home

Fun With SSIS, Script Tasks, and the GAC (Global Assembly Cache)

I learned today that any .NET assembly you want to use from an SSIS script task must be in the GAC. Not only that, I learned that any other .NET assemblies that assembly references must also be in the GAC.

The most fun thing I learned, though, is that the Visual Studio for Applications IDE used for the script task requires that any DLLs you want to reference must not only be in the GAC, but must be physically copied to the appropriate .NET framework folder, which on my machine was C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. Ugggh. And don't forget to copy all of the other assemblies referenced by that assemby also (and don't forget to put those in the GAC). Double ugggh. (Thanks to Jamie Thomson for the heads up on this one. As he points out, this requirement to copy the DLLs is only for development machines; a test or production deployment will find them in the GAC as expected.)

If you're trying to instantiate a .NET class from a script task and it's not in the GAC, you'll receive an error like this:

Could not load file or assembly 'foo.foo' or one of its dependencies. The system cannot find the file specified.


Update 1: something else I learned: if you recompile a DLL that you're using from a script task and update it in the GAC, you have to open up the VSA window for each script task to refresh the reference. Otherwise you will receive an error ing the first script that uses the changed assembly that the assembly could not be loaded. It's possible that it's the incrementing of the version number of the assembly that throws it off, so it may be possible to alleviate this problem during the dev-unit test cycle by not incrementing version numbers on recompile. Update 2: I just now successfully recompiled with an incremented version number, updated the GAC. and ran two script tasks without having to update the tasks as described above...hmmmm...I swear I couldn't get that to work before... Update 2: Yep, sure enough, the very next time I recompiled I ran into the error quoted above. Opening up each script task as described above fixed it.

Update 3: I stumbled across this article that has a nice explanation and illustration of how to set up, reference, and use a .NET assembly from an SSIS script task. (My link is to page 2 of the three page article).

Update 4: I can't confirm this 100% yet, but I believe we have learned that if you are turning off the PreCompile option on your script task in order to keep the package size down then you need to have your DLLs in the .NET Framework folder *even in production*! That's right, when you deploy your package to production, copy those suckers to the framework folder in production, just like on your dev machine. I presume this is because the SSIS engine needs the help of something external to do the compiling at runtime and that this external something requires this. Methinks the integration between SSIS and this ".NET for Applications" engine is not as tight as it could be. (June 13, 06)

Comments welcome.

Hope that helps,
Dan

Thank you

This has saved me a whole heap of head scratching :-)

Good Info

It's nice to find a little plug on how to reference assemblies, but I think it is the most retarded method. To have to copy my assemblies to both the GAC and the .NET folder is really stupid. I have an instance where I want to do something like this, but it is for a client and I'm not certain how willing they will be to do something like that. I really hope future releases will extend the script task to allow references elsewhere and extend that little "script language" drop down to include C#.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Recent comments

User login

About our advertising.

Atom Feed

developer.* Blogs also has an Atom feed, located at this url.

Click here for more information about Atom.

A Jolt Award Finalist
Software Creativity 2.0
Foreword by Tom DeMarco

Recent Posters

Based on most recent 60 days, sorted by # of posts and name.

Google
Web developer.*

Who's online

There are currently 0 users and 21 guests online.

Syndicate

Syndicate content
All views expressed by authors, bloggers, and commentors are their own and do not necessarily reflect the views of developer.* or its proprietors.
Click to read the Copyright Notice.

All content copyright ©2000-2005 by the individual specified authors (and where not specified, copyright by Read Media, LLC). Reprint or redistribute only with written permission from the author and/or developer.*.

www.developerdotstar.com