January 19, 2009 at 1:47 pm
Hey Guys,
I am having a problem casting an object variable.
Code:
Dim UploadRouteInformationClass as ClassLibrary.UploadRouteInformation = new ClassLibrary.UploadRouteInformation
UploadRouteInformationClass.CustomerInvoiceSums = CType(Dts.Variables("Variable").value, ClassLibrary.CustomerInvoiceSums())
Intellicense sees nothing wrong with it, but I get an error when I run it. Error is:
Unable to cast object of type 'System.Object[]' to type 'ClassLibrary.CustomerInvoiceSum[]'.
Before it runs this code, it sets the dts.variable like this:
Dts.Variables("Variable").Value = lCustomerSum (which works great)
I'm completely stuck, I have been trying to cast this thing a million different ways...
January 20, 2009 at 8:22 am
No one?
January 20, 2009 at 10:41 pm
shabazz5th (1/19/2009)
Hey Guys,I am having a problem casting an object variable.
Code:
Dim UploadRouteInformationClass as ClassLibrary.UploadRouteInformation = new ClassLibrary.UploadRouteInformation
UploadRouteInformationClass.CustomerInvoiceSums = CType(Dts.Variables("Variable").value, ClassLibrary.CustomerInvoiceSums())
Intellicense sees nothing wrong with it, but I get an error when I run it. Error is:
Unable to cast object of type 'System.Object[]' to type 'ClassLibrary.CustomerInvoiceSum[]'.
Before it runs this code, it sets the dts.variable like this:
Dts.Variables("Variable").Value = lCustomerSum (which works great)
I'm completely stuck, I have been trying to cast this thing a million different ways...
It looks like your variable contains array of objects (not array of ClassLibrary.CustomerInvoiceSum). Even though the individual items might be of this type, you have to create your required array out of the array of objects. Check the code below:
Dim cisObjs As Object() = CType(Dts.Variables("Variable").value, Object())
Dim cisArr As ClassLibrary.CustomerInvoiceSum[] = New ClassLibrary.CustomerInvoiceSum( cisObjs.Length - 1 )
For item As Integer = 0 To cisObjs.Length - 1
cisArr(item) = CType(cisObjs(item), ClassLibrary.CustomerInvoiceSum)
Next
Give it a try and let us know how it goes.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply