Hello! Since yesterday, I have been encountering an error while using the Invoke Code activity. I have a short piece of C# code that helps cast a JSON text to multiple Dictionary<string, string> collections. The code was working as expected until yesterday.
Here is the exception that Studio is triggering:
Invoke Code: Method not found: ‘System.Collections.Immutable.ImmutableArray`1 System.Reflection.Metadata.MetadataReader.GetBlobContent(System.Reflection.Metadata.BlobHandle)’.
I reviewed the dependencies and the package is installed in the System.Actitivies:
Additionally, I downgraded the System Activities version from 23.10.10 to 23.4.4, but the issue persists. On the forum, there are several topics from users who are experiencing the same error.
Here is the code that I am using in the activity:
try
{
// Deserialize the JSON schema to a dictionary of dictionaries
var outerDict = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(in_JsonSchema);
// Directly access "Config" and "ErrorHandling" from the dictionary
out_configDict = outerDict["Config"];
out_errorHandlingDict = outerDict["ErrorHandling"];
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
I have encountered this issue as well after updating project dependencies. Found a solution by restoring older dependency versions and updating dependencies one by one. In my case looks like the issue was caused by UiPath.PDF.Activities dependency because not updating this dependency from 3.14.1 to 3.16.0 seems to solve this issue (other dependencies were updated and project works).
Thus, I think this to be either an issue with the UiPath.PDF.Activities dependency or, as other have mentioned, an issue with updating dependencies in Windows Legacy projects (my project is Windows Legacy).
I have the same problem. Several robots use the same shared component, which contains an Invoke Code activity. 9 out of 10 robots can execute the Invoke Code without error, one of them threw the error “UiPath Invoke Code: Method not found: ‘System.Collections.Immutable.ImmutableArray`1 System.Reflection.Metadata.MetadataReader.GetBlobContent(System.Reflection.Metadata.BlobHandle)’”.
After downgrading the package UiPath.PDF.Activities from v3.16.0 to v3.14.1 the Invoke Code worked again
This appears to be due to a change in .NET Framework implementations in the System.Collections.Immutable.dll.
UiPath.PDF.Activities 3.16.0 has been built against System.Collections.Immutable 6.0.0.0 while apparently all .NET Framework-compatible UiPath.System.Activities packages have been built against a version no more recent than 5.0.0.0.
Because the GetBlobContent method itself exists in both of these versions with what looks like the same signature, my guess is that a simple difference in the definition of the return type ImmutableArray is what leads to binary-incompatibility between these versions:
5.0.0.0: public partial struct ImmutableArray
6.0.0.0: public readonly partial struct ImmutableArray
The reason projects don’t break when using non-legacy Windows setting is a side-effect of a transition from .NET Framework to .NET 6. The actual reason is that the earliest .NET 6-compatible version of System.Collections.Immutable is 6.0.0.0, so it seems all non-legacy UiPath.System.Activities package versions have also been built against it.