Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Assign Object Variable to an array or list in script (c#)

$
0
0

Hi all,

This one is really throwing me.I have a recordset that writes to a variable called ValidFiles

This works as I use it in a ForEach loop with no problem.

Now I want to read ValidFiles into an array or list to work with in a script.

I thought it would work like this :

string[] ValidFiles = (string[])(Dts.Variables["ValidFiles"].Value);

But I am getting this error when it runs:

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to class type 'System.Object[]'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.What am I doing wrong ?

I have searched the web but cannot find any solutions so any help much appreciated.

Thanks in advance


Viewing all articles
Browse latest Browse all 24688

Trending Articles