I have used invoke code activity and written C# code in it with some passed arguments. Everything works fine. When I assigned a datatable variable(did put default value) in the workflow and passed it to the invoke code activity. When I run this activity I am getting target of invocation failed for the datatable argument inside the code. any idea?
Invoke Code is strictly for VB.NETif your project is set to VB.NET. C# support got in a while ago but then was removed so I assume you’re using an older version.
In any case, you can in fact use C# code if your entire project is set to C# (and things like the code you write in Assign and Invoke Method activities will use C# syntax), however, the error you’re getting is a generic “Something went wrong inside this code snippet”, that is to say, you won’t get the full exception trace.
My only suggestions would be to double check that the name of the variables used as argument are the correct ones, and then double check your code.
@Krsna
Lets assume you have an empty datatable with 2 Columns
Filling it up the Datatable with the dictionary entries can be done with LINQ
Use an Assign Acitivity
Left side: YourDatatableVar
Right side:
(From kvp In YourDictionaryVar
Let ra = new Object(){kvp.Key,kvp.Value}
Select YourDatatableVar.Rows.Add(ra)).CopyToDataTable