Using Linq query throws 'netstandard' reference error

I’m currently trying to work my way through some tutorials and have run into an issue. I’m attempting to use a linq query on a simple list of strings but every time I use linq at all it throws the following error…

RemoteException wrapping System.InvalidOperationException: Compilation failures occurred:

The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

I’ve not added any references to anything outside of what’s already added when you create a new process. I’m using C#. My linq query is: (from c in countries.AsEnumerable() orderby c select c). My List of strings is: new List() {“Germany”, “Spain”, “Japan”, “Brazil”, “India”, “China”};. I tried to back up the version of all packages to the non-preview versions but that doesn’t work either. I do however get a different error when I do this:

Message: Compilation failures occurred:

Unable to load assembly 'UiPath.OCR.Activities.Design'.	
Unable to load assembly 'UiPath.UIAutomationCore'.	

The type 'System.Object' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

Anyone have any ideas?

You should need to define list in UIpATH like this
YourList= New List(Of String)(New String() {“New”, “Old”,“Apple”})

YourList.OrderBy(Function(x) x).ToList()

It will Sort your list. Thanks

Try using vb.net instead of C#. I know uipath has added c# functionality with some versions (but not all). I’m also not sure if you have to set that language somewhere within settings as i haven’t used it myself.

There are online calculators that do a decent job switching back and forth between vb.net and c# syntax - i usually use either of these 2: https://www.carlosag.net/tools/codetranslator/ or http://converter.telerik.com/

I’m guessing your example was purposefully simple, but just in case that is your real use case there isn’t a reason for using linq for something this simple. You can just use List.Sort instead :slight_smile:

I created a process using vb.net and they all work fine now. I’ve used the telerik converter extensively. It’s very useful. Thanks.

None of the LINQ syntax seems to work (including .Sort()) while using C#. Where would be the appropriate place to report this bug?

I having the same problem and really don’t want to switch to vb . Does anyone found a solution ? I mean linq is a great help and I would like to use it with c#. Thank you