Add to Dictionary compiler error - disallows implicit conversion

Compiler error(s) encountered processing expression “Data_Dictionary”.
Option Strict On disallows implicit conversions from ‘System.Collections.Generic.Dictionary(Of String, String)’ to 'System.Collections.Generic.IDictionary(Of Object, Object)

I’m trying to add a new string to a dictionary, the dictionary is created and populated with data in one sequence using the Add to Dictionary activity then returned to the main process, another sequence is invoked and returns a string. When trying to add that string to the dictionary I get the above error message. Nowhere is the dictionary declared to be of that type and both the key and value are strings. Any ideas where I’m going wrong here?

@peter.wolodkin
Welcome to the forum!

  • on variable Panel define a variable and configure the Datatype to Dictionary (String, String)

  • within an assign activity you can add an entry like this
    to: yourDictVar(“Company”) will geth the value “UiPath”

Hey thanks for responding, the dictionary is already defined as Dictionary<String,String> and I’m still getting this error.

Check all datatype definitions of variables, arguments the issue would come from this

Kindly note :
System.Collections.Generic.IDictionary(Of Object, Object)
an IDictionary is not the same as a Dictionary

refer to the screenshot above for more help on this

I found the issue, the activity needed to be declared as <String, String> when you create it. When creating an Add to Dictionary Activity from the activities panel and dragging it into the workflow you get a pop up to select the types. I added this one by clicking the Add Activity (+) button and the popup never opened so it defaulted to <Object, Object>.

2 Likes

Perfect happy automation :+1:

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