"XAML Cannot Be Opened. Document Is Invalid" Error Message When Attempting To Open A XAML File

How to trouble shoot "XAMlcannot be opened. Document is invalid" error message when attempting to open a XAML file?

Root Cause: This issue usually occurs, when either the XAML file is corrupted or modified manually and is missing the required information.

Couple of the known root causes of this issue are as follows:

  • Corrupted XAML file
  • Manually modify XAML file .

Resolution: The best way to troubleshoot this issue would be to obtain a working copy of the XAML file and compare it against the XAML file which is giving the error.

Ways to obtain a working copy, From
  1. The code repository (if configured)
  2. The Orchestrator (if an older version is published)
  3. A Studio/ Robot machine where the project was previously executed, at the following location,
  • C:\Users\\.nuget\packages\\\lib\net45
Or
  • %userprofile%\.nuget\packages\\\lib\net45
The above location is the default location where the project files are extracted for execution by the Robot unless customized during installation.

Once a working copy of the XAML file is obtained, the copy with the issue and the working copy would have to be compared. One tool that can be used to carry out this activity is the Notepad++ text editor and the "Compare" plugin available for the same (links shared in the reference section). This will help to understand the differences and fix any if needed.


Alternative: Another way to compare two XAML files is to read the file as text and use de-serialize XAML (from WebAPI) in order to compare any nodes.


Another tested solving approach is to do a clean re-install of Studio.
After uninstalling Studio, make sure to manually delete all the associated folders as per the Studio - Modify or Uninstall Studio page.
After deleting the data, install Studio.