Unexptected error has occurred during the library compilation Process

Project language: C#
Dependencies:
image
Studio version: 2023.4.1

I have never had this problem before when using projects with VB.
The problem occurs when I try to run the entire project. When I run the affected flow it works in most cases.

image

image

image

Sometimes it manages to come a bit further in the compilation process. I really have no clue what to do, Tried to remove some invokes here and there and it sometimes manages to progress but then it fails on another flow. Upgraded some of the dependencies.

What can I do?

Check by downgrading the packages

You have a data typing error.

As it states it cannot convert an Object to a Bool since the object might not be a boolean, it could be a string or something.
Those logs are not showing you the affected workflow as the compilation, as I understand it, runs multithreaded .

This is unrelated to your project being C# and the same happens in VB.NET if you get a wrong data type in one of your workflows.

As for the second exception, that is indeed more related to C#, its a better language but its more strict. You basically cannot use variable names which are also data types.
When you type ‘Exception’ it thinks you mean the class, not the variable you apparently have set.

1 Like

Hi @Jon_Smith

I just thoroughly went through all my flows and activities and I found the issues.

For the first problem with the “Are you missing a cast?”, The issue was hard to spot but it was located in the xaml file:

For some reason The Type was set to Object, I have now clue why (green).
I created a new assign(Yellow) and it looks better now, and the first compilation error is gone.

For the second problem the issue was this:

"Failed to save files. Exception message: " + Exception.Message +" at Source: "+ Exception.Source

In VB.net “Exception.Message” and “Exception.Source” works but not in C# it seems, so that was my mistake. After changing it to “exception.Message” and “exception.Source” (lower case “E”) it works and the second compilation error is gone.

So the first error was tricky and I dont know why it happened and the second one I can see the problem.

Nevertheless I wish that the compilation error message could identify the specific acitivity causing the error to minimize the time searching for the problem. Is there a way to find such errors fast/easier?

Nice work,

The first issue is because the data type inference went wrong, which can sometimes happen when you change data types etc.
Basically assign activities needs to handle all data types and dynamically changes based on the values you use, so it may be string, int, boolean etc. Sometimes this goes wrong and one or both sides get stuck as Object or another data type.
Remaking the assign usually solves this and it correctly assigns the data type.

As I mentioned above, VB.NET is an overly forgiving language.
When you type ‘Exception’ you should be referring to the System.Exception class and not a variable, but VB.NET just fudges it and lets it go. C# is stricter, if say Exception it assumes you mean the class since you shouldnt name your variables the same as the class type name.

I have no tips for finding those errors faster, it indeed would be great if the logs were clearer on what workflow at least the compilation error is in as just checking the last one doesn’t help due to multithreading.

1 Like

Thanks, yeah after using VB.NET projects in UiPath for a couple of years there is a transition period to get a hang of C# syntax I guess, started using C# projects a couple of weeks ago because it seems more future proof.

Thanks for your input.

C# is a much much much better language than VB.NET, things like that make it a ton more reliable and consistent aswell as the syntax just being better with the exception of a few small areas just as their And and Or operators.

I hate having to use VB.NET when C# is available.