Unable To Cast Object Of Type ‘UiPath.Service.PasswordCredential’ To Type ‘UiPath.Service.IdentityCredential’

While running the jobs from command prompt under locked screen conditions, the job fails with error : RemoteException wrapping System.InvalidCastException: Unable to cast object of type ‘UiPath.Service.PasswordCredential’ to type ‘UiPath.Service.IdentityCredential’. at UiPath.Service.Job.StartAsync(IUserCredential credential)

This is not a supported scenario where the process is triggered from Agent/ Assistant under the locked screen, but this approach is frequently used to work with command line.

Starting from 21.10.x onward even command prompt execution under locked screen would not work and the error should be thrown in terms of Selectors or Desktop disconnection etc.

But the error which is reported while running from command prompt is related to the Identity credentials and this error has been raised as a bug and will be resolved in future releases. To workaround this error, below steps can be followed,

  • Open Credential Manager from the Start Menu
  • In Generic credentials, look for a credential that looks like “UiPath:user=…” and remove it

Note: Even after above steps, the selector errors are thrown due to unsupported scenario.

Refer the UiPath Forum post Robot 21.10 Crashes When Trying To Start Job From The Command Line .