Any reason for which OCR activities don't work in a C# project?

Read PDF with OCR in particular.

I need to read a PDF with OCR and I wanted to test it inside a C# project as I’m more comfortable with this language.

Unfortunately I get an error when compiling:

Read PDF With OCR: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.

I started messing around with dependencies to no avail, so I created a new VB project and it works correctly.

Is there any reason why it doesn’t work in C# or how to make it work?

This is another drawback I randomly see when doing something in C#, it is unfortunate if there are more things like this especially if they occur later on in a project that I start in C# as I’d like to avoid rewriting in VB or having to create custom activities or invoking C# (which again likes to randomly fail in a VB project, especially legacy ones)

My dependencies (are all needed for a simple OCR read?):

image

@dor
Use stable pdf package version not preview one.It may help in your case

Thanks for the answer.

Sorry, the screenshot is a bit misleading, in the C# project the PDF package was on stable version, screenshot is from VB version.

However after your comment I went to the C# version and changed all packages to the latest stable versions.

I still get the same error:

System.NotSupportedException: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.

Is this a C# limitation or is there a workaround?

image

Hey,

Thanks for the answer, it does not apply to my case as I do not hardcode any strings in the test workflow which might cause the quotation marks to fail, however it prompted me to create another project, this time a C# Windows - Legacy project and the workflow compiles correctly.

For me this is a major bug right now (especially if it’s a quotation mark issue), as UiPath wants to deprecate the Legacy configuration while the Windows configuration is missing C# things right now, which makes me wonder if the C# option is a novelty right now that is not taken care of. There is no REF template for Windows/C# either.

Hi,

Which version of Studio do you use? In my environment, some occurs same issue, but some doesn’t.

Regards,

Today I tested on Community 2022.10.3, no option to check Enterprise right now.

Hi,

In my environment CE22.10.3 on hand works well, but 22.4.6 in my office doesn’t work. I’ll check it in details tomorrow.

Regards,

In which setup does it work in though?

For me:
VB Legacy - works
VB dotnet 6 - works
C# Legacy - works
C# dotnet 6 - doesnt work

All latest stable activities

Hi,

C# -Windows(net6) as the following.

Regards,

Hi,

In this morning, I confirmed I could reproduce the issue in my environment (Studio22.4.6+Windows C# project) as the following.

08:27:20.1476 => [ERROR] [UiPath.Studio.App.Logging.OutputLogger] [57] Read PDF With OCR: Expression Activity type 'VisualBasicValue`1' requires compilation in order to run.  Please ensure that the workflow has been compiled.

However, after I upgrade / downgrade some packages several times, the issue suddenly doesn’t occur. And I cannot reproduce the issue after that even if I restore version of activities package.

Regards,

Nice find. Which packages do you have (directly) installed in the project that compiles succesfully? Some are dependencies for others so maybe I don’t need that much on the list.

HI,

I just upgraded UiPath.SystemActitites to the latest.(because my studio is 22.4.6) However, I cannot reproduce issue now, even if i roll back the version. This might mean the matter isn’t caused by version of package…
If possible, can you share your project which the issue occurs? It’s no problem if dummy.

Regards,

Hey,

Attached my sandbox workflow, just tried to compile it and same VBValue error.
OCR.7z (261.9 KB)

Hi,

Thank you for sharing your project files. Finally, I just figure out the condition of reproducing the issue.

This issue seems to occur under the following condition.

  • Windows compatibility
  • C#
  • There are 1 or more activities which can be have variable after ReadPDFwithOCR activity.

I tried to fix the xaml file manually but no luck. I think it’s something bug of the activity.
As a workaround, we can avoid this by not match the above 3rd condition.
More specifically, create xaml file which has just ReadPDFwithOCR acitivty, then call it, as the following.

image

OCRv2.zip (57.6 KB)

Regards,

2 Likes