Cannot cast a data profiling task object to DataProfilingTask in SSIS

Hi,

I am trying to programatically execute an SSIS package containing only a single data profiling task. 

		var pkg = app.LoadPackage(@"c:\Package.dtsx", null);
                var task = pkg.Executables[0] as TaskHost;
                var dpt = task.InnerObject as DataProfilingTask;

The package is read properly and debugger shows that "task.InnerObject" is an object of DataProfilingTask.

But the dpt variable contains a null value instead.


May 21st, 2015 8:26pm

What is the purpose of

var task = pkg.Executables[0] as TaskHost;
                var dpt = task.InnerObject as DataProfilingTask;

To execute the package you need only to

var res = pkg.Execute();

and check the value o

Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2015 1:13pm

Hi @ArthurZ,

Actually I want to access the default DataProfilingTask and modify its properties. Right now there is only one task in the package.

Cheers,


May 24th, 2015 10:38pm

DO you mean you're trying to do something like this?

http://tonikielo.blogspot.ae/2010/02/data-profiling-in-c-with-ssis.html

Free Windows Admin Tool Kit Click here and download it now
May 25th, 2015 1:25am

Hi @ArthurZ,

Actually I want to access the default DataProfilingTask and modify its properties. Right now there is only one task in the package.

Cheers,


May 25th, 2015 2:36am

Hi,

Thanks for your reply. Actually the 3 lines of code that I have mentioned is taken from this blog. The problem happens when I try to get the object for DataProfilingTask which is already added in the Package. 

For me the following line return null, so I cannot really do anything with that.

var dpt = task.InnerObject as DataProfilingTask;

I also tried adding a new DataProfilingTask to the package instead of just loading an existing one using following code. 

 var pkgType = typeof(Microsoft.SqlServer.Dts.Tasks.DataProfilingTask.DataProfilingTask).AssemblyQualifiedName;
                Executable exec = pkg.Executables.Add(pkgType);

And I get following exception :

Error: {0}Cannot create a task from XML for task \"\", type \"\" due to error 0xC001F430 \"An error occurred while accessing an internal object. This could indicate a custom extension built for Integration Services 2005 is being used.\".\r\n"

Free Windows Admin Tool Kit Click here and download it now
May 25th, 2015 6:33pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics