Invoke Code -Error BC30574 Option Strict On disallows late binding At line 9

Code in Invoke Code Error is:
Dim objs As array = { _
New With { .Item=“A”, .Loc=“L1”, .Q1 = 1, .Q2=0}, _
New With { .Item=“A”, .Loc=“L1”, .Q1 = 2, .Q2=1}, _
New With { .Item=“B”, .Loc=“L1”, .Q1 = 3, .Q2=99}, _
New With { .Item=“B”, .Loc=“L2”, .Q1 = 7, .Q2=0} _

Dim Query As IEnumerable
query= From e In objs Group e By key= New With { key e.Item, key e.Loc } Into g=Group _
Select New With { _
.key = key.toString, _
.value = New With { _
.Q1 = g.sum(Function(x) x.Q1), _
.Q2 = g.sum(Function(x) x.Q2), _
.Count = g.Count _
} _
Any help,thanks a lot.

Hi @cllrebecca,

The thing is that UiPath Invoke code activities allow strict option. So, while developing the code in Visual studio, make sure that the first line of the code is

           Option Strict On; 

And coming to the point, As quoted, e and g are not recogning in the code.

Just hover on each variable you have in the line which is erroring out. If the variable is working fine, it will show the details and the type of the argument… If it is not, then it will throw the error.
For the above code, e and g are giving errors and you need to convert them to the required type using CType conversion available in VB

Is there a way to set Option Strict OFF? In above code, e is Anonymous Class.

I think the error is about late binding due to Option Strict is on, so I want to turn it off ,but dont know how to.

Instead of trying to change it to OFF, can you try converting the each variable to a defined and required type?

Or else just declare the variables as required type in the code. These will resolve the issue. :slight_smile:

Try and let me know @cllrebecca… You are almost done, just need to declare those two variables