C# throws Query Interface exception when casting to DTS.DataPumpTask
Posted on 2004-08-27
I created a sample DataPump Package using the DTS GUI in Enterprise manager and exported it to VBScript. I put it in a VB6 project and it worked fine.
Dim oTask As DTS.Task
Dim oBulkDataPump As DTS.DataPumpTask
... Package & Step creation omitted...
Set oTask = oPackage.Tasks.New("DTSDataPumpTask")
Set oBulkDataPump = oTask.CustomTask
...Properties, Transformation and execution stuff omitted....
The above code works fine.
I converted it to C# solution.
DTS.Task task= mPkg.Tasks.New( "DTSDataPumpTask");
DTS.DataPumpTask pump = (DTS.DataPumpTask)task.CustomTask;
....setting DTS.DataPumpTask properties omitted....
At *runtime, the above code throws a Query interface exception when creating the pump;
Upon examining the DTS.DataPumpTask interface, sure enough, it does not extend DTS.CustomTask. And certainly DTS.CustomTask does not extend DTS.DataPumpTask.
What do I have to add to my C# code to make it behave like the old VB6 code? Somehow I feel I need a different mechanism to get the correct interface than class casting.
The Project references I've added are to the version 2 of the DTS com libraries. The interop client callable wrapper dlls are in my bin directory. And everything compiles cleanly.
What am I missing?
Thanks in advance