Win32Exception Error In UI Interaction

Issue Description:

The bot was throwing error: System.ComponentModel.Win32Exception (0x80004005): The handle is invalid,
at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) while running the Robot in Unattended mode.

While running the Robot in Unattended mode it gives below error,

System.ComponentModel.Win32Exception (0x80004005): The handle is invalid

at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) while running the bot in unattended mode.

Resolution:

  • The package was published as background process and hence the Robot was unable to do the UiAutomations as the Robots sessions were not being created.
  • Convert the background process to foreground one in the project settings and republish the package from Studio.

  • Set the "Starts in Background" values as "No" for UiAutomations in an Unattended mode.