Invoke Code - code writen in C# - trying to convert a dictionary to datatable


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?


Hi @Krsna,

Invoke code is strictly for VB dotNET. Click here for cross-reference.

well, if that is the case, then whey there is language option to select from (VBNet and CSharp) in properties section?

Invoke Code is strictly for VB.NET if 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.

1 Like


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

I have resolved it now, thanks. I did not put the initialisation of table columns correctly. When I did it resolved.

Thanks for your replies

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.