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: CodeTranslator: Code Translation From VB.NET <-> C# <-> TypeScript <-> Java 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?

1 Like

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

1 Like

I get the same error trying to create an enumeration in a “for each”-activity. First it worked fine with the range(0 to 1)={0,1} then I got creative and changed it to range(offset to offset+1)={7,8} then the error occurred and now it won’t accept any enumerations.
Haven’t tried restarting my PC, but will do that now.

I was using MongoDB.Entities and had this error.

After deleting the folder in
C:\Users\USERNAME.nuget\packages\mongodb.entities

I edited the file
MongoDB.Entities.csproj
from:

netstandard2.0
to:

netstandard2.0;net461

recompiling, and reinstalling the package in uipath, my error went away.

If using MongoDB Entities, this is how to initialize the connection:

DB.InitAsync(strDatabase,MongoClientSettings.FromConnectionString(strConnectionstring));

Only solution seems changing c# to vb.net i guess. Is anybody found useful answer why this problem is happening?

I have the same problem and it pisses me off.
The more so because it is the fault of the system libraries. Because it works without any problems on 1 computer and it does not work on 2 others. Maybe someone from Uipath will finally fix it !? or at least say what needs to be done to make it work?

Not true!. This is the packet fault in windows. I do not know which ones, but to the bank. As I wrote, it works for me on 1 computer and not on 2 others.

I recently had the issue when trying to communicate to the planner using Microsoft Office 365. I solved it by installing the older versions of Microsoft Office 365, a cooked way to solve it, but it works.

I had the same netstandard error with a xaml file that reads Excel via ExcelProcessScope, nothing special in it. I copied the xaml from another project where it was working just fine but in the new project to where I copied it, I got the error.

I resolved the error by removing unused imports from the xaml file.

Hopefully this helps someone who’s struggling with this!