System invalidcastexception "Unable to cast object of type"

  • Thread starter Thread starter kdinuk
  • Start date Start date
K

kdinuk

Guest
Hi, I'm getting an error...

System.InvalidCastException: "Unable to cast object of type

'Mircrosoft.SqlServer.Dts.Runtime.Sequence' to type

'Mircrosoft.SqlServer.Dts.Runtime.taskHost'.

1595394.jpg

string pkgLocation;
DtsRuntime.Package pkg;
DtsRuntime.Application app;

pkgLocation = path;
app = new DtsRuntime.Application();
pkg = app.LoadPackage(pkgLocation, null);

//List Executables (Tasks)
foreach (DtsRuntime.Executable tsk in pkg.Executables)
{
DtsRuntime.TaskHost TH = (DtsRuntime.TaskHost)tsk; //getting an error here
treeView1.Nodes["Executables"].Nodes.Add(TH.Name, TH.Name);
//Data Flow Task components
if (TH.InnerObject.ToString() == "System.__ComObject")
{
try
{
DtsWrapper.MainPipe m = (DtsWrapper.MainPipe)TH.InnerObject;
DtsWrapper.IDTSComponentMetaDataCollection100 mdc = m.ComponentMetaDataCollection;

foreach (DtsWrapper.IDTSComponentMetaData100 md in mdc)
{
//MessageBox.Show(TH.Name.ToString() + " - " + md.Name.ToString());
treeView1.Nodes["Executables"].Nodes[TH.Name].Nodes.Add(md.Name, md.Name);
}

}
catch
{
}

Continue reading...
 
Back
Top