OCR Engine throws: RemoteException wrapping System.Exception: An unexpected error has occurred ---> RemoteException wrapping System.AggregateException: One or more errors occurred.

When using an OCR engine activity, the following exception is thrown: RemoteException wrapping System.Exception: An unexpected error has occurred ---> RemoteException wrapping System.AggregateException: One or more errors occurred. ---> RemoteException wrapping System.AggregateException: One or more errors occurred

Issue Description

When using an OCR engine activity, the following exception is thrown: RemoteException wrapping System.Exception: An unexpected error has occurred ---> RemoteException wrapping System.AggregateException: One or more errors occurred. ---> RemoteException wrapping System.AggregateException: One or more errors occurred

Root Cause

The OCR activity works by launching an executable called UiPath.VisionHost.exe (the name can vary depending on the OCR engine). The additional process does the work of actually running the OCR engine and then it communicates the generated information back to the UiPath Robot using a named pipe.

If the Vision host process faces an issue, or the pipe communication fails, then this error can be encountered.

Diagnosing

  1. The first place to look is at the vision host logs. These can be found at %localappdata%\UiPath\Logs. The name convention will be <Date Stamp>_VisionHost.log. The name might be slightly different depending on the OCR engine that is being used.
    • Name could be VisionOmniPageHost.log for omnipage
    • For UiPath OCR it will be UiPathOCRActivitiesHost.log
    • Etc.
  2. Check the above logs for any exceptions. Most common cause would be if the OCR engine is using an HTTP endpoint and the connection failed.
    • For example using the UiPath OCR engine with an invalid OCR key will look like: Fatal UiPath.Vision.OCR.OCRException: {"info":"Prediction Failed","reason":"{\"message\": \"Invalid api_key requested\"}"}
      UiPathOCRErrorInvalidResponse
    • Typically the error in this log will explain the issue, but if it is not clear, raise an issue with UiPath.
  3. If the log has no errors, that most likely means the issue is with the named pipe communication. Some basic things that can be checked:"
    • Check to see if it occurs with other users.
    • Check to see if it occurs on other machines.
    • In some scenarios, it could be that Anti-virus is blocking the communication. If this is the case it activity will most likely always fail.
    • Additionally, try different OCR activities to help see if this affects all activities.
  4. If none of the above steps help identify the issue, open a ticket with UiPath. When the VisionHost log does not reveal the issue, it means that a very unexpected error is occurring and WCF tracing will have to be enabled. UiPath can help generate these logs.
    • In this scenario, tracing would be enabled for the UiPath Robot executor process and for the Vision host process.
    • For context see here
    • As mentioned, it would be better to reach out to UiPath for help with this.