Cannot assign from type 'System.Object' to type 'System.Collections.Generic.IEnumerable`1[UiPath.Platform.ResourceHandling.IResource]' in Assign activity 'Assign'

Cannot assign from type ‘System.Object’ to type ‘System.Collections.Generic.IEnumerable`1[UiPath.Platform.ResourceHandling.IResource]’ in Assign activity ‘Assign’.

@Ejaz_Ab This error occurs because the Assign activity is trying to assign a value of type Object to a variable of type IEnumerable. Since UiPath cannot automatically convert Object to a strongly typed collection, you need to cast the value to the correct type.

resources = CType(resultObject, IEnumerable(Of UiPath.Platform.ResourceHandling.IResource))

@Ejaz_Ab

Can you show what you are trying to assign to this variable here? It looks like you are trying to assign Object to IResource variable which couldn’t be done.

Hi @Ejaz_Ab ,

In the Assign activity , convert the object.

Example:

resources = CType(outputObject, IEnumerable(Of UiPath.Platform.ResourceHandling.IResource))

Where:

  • outputObject → variable of type Object
  • resources → variable of type
    IEnumerable(Of UiPath.Platform.ResourceHandling.IResource)

Let me know if this works for you

Thanks,
NaNi