BC36914 cannot infer an element type,and option stricts does no allow object to be assumed


Hello community!

Iam getting this error when iam using the variable type IEnumerable variable type,Before also i have used this approach in many projects but that time there was no such kind of error,But after updating the UiPath i got this error,Iam using this approach to append the file name once it is downloaded,so that bot will not download the same file again.

These things get trickier in Windows compatibility. I suggest using IList(Object) instead of IEnumerable. Then you can use the Append Item to List activity to add to it.

Easiest way to create the correct variable is to add the “Append Item to List” activity, put your cursor into the List property, press CTRL+K, type the variable name, then press enter.

Can you try the syntax proposed here? Studio - Deprecation of the Windows-Legacy Compatibility → “Known limitations”.

Hi @Priyesh_Shetty

This syntax is not compatible with windows project only works in Legacy. Use this one instead

new Object() {} 

Cheers

@rikulsilva i tried this then too it is showing error.

@postwick
I have never used this activity…Scenerio is i have stored multiple file name in array.So while downloading the files it downloads the same file twice.so how can i add the downloaded file name using this activity?

The Type can BE derived when defined before the brackets. E.g

New String(){}

Or

Enumerable.Empty(of String)
Enumerable.Empty(of String).ToArray()
Enumerable.Empty(of String).ToList()

Etc

1 Like

Hi @Priyesh_Shetty
For Array:

arrEmpty = New String() {}

Using Enumerable.Empty Method for Array:

arrEmpty = Enumerable.Empty(Of String)().ToArray()

For List:

listEmpty = New List(Of String)()

Using Enumerable.Empty Method for List:

listEmpty = Enumerable.Empty(Of String)().ToList()

Hope it helps!!

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