I have written this code to implement an SSIS control flow task that fetches a file over HTTP:
using System;
using Microsoft.SqlServer.Dts.Runtime;
namespace Ht
I was able to recreate the issue that you are facing. Following example describes how to recreate the issue and also how to fix it. I used Visual Studio 2010
to create the class library DLL but the target framework version was 2.0. The Control Flow task was then added to SSIS 2008 R2
project, which is more or less same as SSIS 2008.
Step-by-step process:
In Visual Studio 2010 IDE, created a C# class library project and named it as HttpTask. Refer screenshot #1. Deleted all the references except the required ones. Added a reference to the DLL Microsoft.SQLServer.ManagedDTS, which was available in the path c:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SQLServer.ManagedDTS.dll
in my machine. The path can be different based on the version of SQL Server that you have installed. 100 in the path represents either SQL Server 2008 or SQL Server 2008 R2.
Renamed the class Program.cs to HttpTask.cs
and pasted the code shown in screenshot #2. The code is exactly same as what is provided in the question. Code is also provided under the C# Class Code section.
On the class library project Properties, changed the target framework version to .NET Framework 2.0
. Refer screenshot #3.
Configured the Post-build event command line as shown in screenshots #4 and #5. The gacutil.exe path on my machine was C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe
. The path could be different in your machine. The script is also provided Post-Build event command line section.
The class library was not signed at this time. Refer the screenshot #6.
The project was built but the dll was not registered in GAC (Global Assembly Cache). Refer screenshot #7.
Verified that the DLL was correctly copied to the path C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Tasks\
. Refer screenshot #8.
Verified that the DLL was not present in the GAC folder C:\windows\assembly
. Refer screenshot #9.
Created a new SSIS package. On the SSIS package's Control Flow tab's tool box, right-clicked on the section Control Flow Items
and selected Choose Items...
. Refer screenshot #10.
On the Choose Toolbox Items, selected the SSIS Control Flow Items
tab and selected the control HTTP Task. Refer screnshot #11.
Tried to drag and drop the task on to the Control Flow tab and received the same error as shown in the question. Refer screenshot #12. So the above steps described how to simulate the issue. Now, the following steps describe how to fix it.
Now, I went back to the Class library project and clicked on the Properties. This time I signed the project with Strong Name Key. Refer screenshot #13.
Verified that the strong name key file was added to the project. Refer screenshot #14.
Built the project. This time the DLL was successfully added to the GAC. Refer screenshot #15.
Verified that the DLL was correctly copied to the path C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Tasks\
. Refer screenshot #8.
Verified that the DLL was present in the GAC folder C:\windows\assembly
. Refer screenshot #16.
On the SSIS package, deleted the control HTTP Task from Control Flow Items section in the Toolbox. Refer screenshot #17.
Repeated the steps #9 and #10 to add the task again to the toolbox.
Dragged and dropped the task on to the Control Flow tab and the task appeared correctly. There were no errors this time. Refer screenshot #18.
Hope that helps.
C# Class Code:
using Microsoft.SqlServer.Dts.Runtime;
namespace HttpTask
{
[DtsTask(
DisplayName = "HTTP Task",
TaskContact = "Iain Elder",
RequiredProductLevel = DTSProductLevel.None
)]
public class HttpTask : Task
{
public string LocalPath { get; set; }
public string Connection { get; set; }
public bool OverwriteDestination { get; set; }
public DTSExecResult Execute(Connections connections,
VariableDispenser dispenser, IDTSComponentEvents events,
IDTSLogging log, object transaction)
{
HttpClientConnection http = AcquireHttpConnection(connections);
http.DownloadFile(this.LocalPath, this.OverwriteDestination);
return DTSExecResult.Success;
}
private HttpClientConnection AcquireHttpConnection(Connections connections)
{
ConnectionManager cm = connections[this.Connection];
object nativeConnection = cm.AcquireConnection(null);
return new HttpClientConnection(nativeConnection);
}
}
}
Post-build event command line:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe"
/if "$(TargetPath)"
copy $(TargetFileName)
"C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Tasks\"
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
Screenshot #5:
Screenshot #6:
Screenshot #7:
Screenshot #8:
Screenshot #9:
Screenshot #10:
Screenshot #11:
Screenshot #12:
Screenshot #13:
Screenshot #14:
Screenshot #15:
Screenshot #16:
Screenshot #17:
Screenshot #18: