Saturday, November 27, 2010

“The name 'Dts' does not exist in the current context” with CodePlex sample packages

I downloaded SSIS sample packages from http://www.codeplex.com/ but couldn’t run them with the following error.
The name 'Dts' does not exist in the current context
It took me for a while to figure out what’s wrong. I’d like to share and notes my experience.
Script Task indicates red ‘x’. So I launched Script Task Editor then clicked “Edit Script” button.
Expand References in Project Explorer then I found a reference to Microsoft.SqlServer.ScriptTask is missing. The reference refers to GAC.
I looked through C:\Windows\assembly and didn’t find Microsoft.SqlServer.ScriptTask.

Solutions:
We have two options.

a) Change the reference to "C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.ScriptTask.dll" or "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.ScriptTask.dll"

b)
Register the Microsoft.SqlServer.ScriptTask.dll (x64 or x86) into GAC using gacutil.exe.

Notes:
I’m not sure if SQL Server 2008 R2 should register the assembly into GAC or not.
If you add Script Task then edit script, the script refers to the assembly in the “C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\”, not to GAC by default. So it doesn’t matter whether it is in GAC or not by default.

3 comments:

  1. Used option (a) but it didn't work for me, any idea?
    FYI I am using VS2012

    ReplyDelete
  2. Changed the Reference
    From
    "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.ScriptTask.dll"
    To
    "C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.ScriptTask.dll"

    And It worked.

    Thanks for your help.

    Please ignore my previous Comments

    ReplyDelete
  3. Mine works by deleting both references to script task and dts and then add it back in.

    ReplyDelete