0

In MTM when tried to access Lab environment I got the below error message :

Server was unable to process request. ---> There was an error generating the XML document. ---> Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

enter image description here

I did check the solution in the this link. But it suggests that I should delete the environments using sql queries, which I don't want to do (and also I don't have access to database).

Can anyone please suggest some other way of fixing it.

Note : This is happening with most of the projects present in collection however for 2 projects it is not giving any error in MTM Lab centre

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
Pankaj Devrani
  • 510
  • 1
  • 10
  • 28

1 Answers1

0

You can try below things to narrow down the issue:

1. Try to clear TFS cache in your client machine, then try it again.

The corresponding Tfs folders to manually delete are as follows:

Tfs 2017: "%localappdata%\Microsoft\Team Foundation\7.0\Cache\"
Tfs 2015: "%localappdata%\Microsoft\Team Foundation\6.0\Cache\"
Tfs 2013: "%localappdata%\Microsoft\Team Foundation\5.0\Cache\"
Tfs 2012: "%localappdata%\Microsoft\Team Foundation\4.0\Cache\"

You can copy and save the following content to a .bat file, then execute on the client machine to delete the caches.

@echo off
ECHO **********************************************************
ECHO Delete the Tfs 2017 client cache
ECHO **********************************************************
rmdir "%localappdata%\Microsoft\Team Foundation\7.0\Cache\" /s /q
ECHO "All Done!"

2. Querying Lab Environments Using TFS Lab Management APIs, then compare with the environments in MTM, to check if there are any differences (NOT EXISTS ones).

3. Delete Lab Environments with tfsconfig lab /delete command.

  • This command will remove all group hosts, library shares, and environments from team project collection.

  • Recreate the lab environments, see Creating Lab Environments

If that still doesn't work, then I'am afraid that you have to ask the admin to grant the permission to access the database, then try the solution mentioned in this link.

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • I tried with [Querying Lab Environments Using TFS Lab Management APIs](https://blogs.msdn.microsoft.com/devops/2014/04/02/querying-lab-environments-using-tfs-lab-management-apis/) but the code given in same error which I am getting in MTM when I trying to get the list of environment in the code "ICollection envList = labService.QueryLabEnvironments(querySpec);" the error message is "Server was unable to process request. ---> There was an error generating the XML document. ---> Index was out of range. Must be non-negative and less than the size of the collection." – Pankaj Devrani May 18 '18 at 05:48
  • I tried point one already but it didn't work also about point 3 - I cannot delete all the environments. Is it possible to delete environment by specific name from a particular project present in tfs instead of deleting all of them? – Pankaj Devrani May 18 '18 at 05:52
  • @PankajDevrani As far as I know, no such commands to delete environment by specific name. In this case I suggest asking admin to grant permissions to access the DB. Then backup the database first and try the solution mentioned in the link. – Andy Li-MSFT May 18 '18 at 06:07
  • Also I use VSTS can you tell how can it be done in VSTS? – Pankaj Devrani May 18 '18 at 06:08
  • @PankajDevrani Unfortunately for VSTS we cannot manage the DB directly. Have you tried other user account? Just check if other team members have the same issue. – Andy Li-MSFT May 18 '18 at 06:26
  • Yes I did tried the other accounts and all are facing the same issue. – Pankaj Devrani May 18 '18 at 06:29
  • @PankajDevrani Seems it's an VSTS issue. Suggest you submitting a feedback/defect to developercommunity : https://developercommunity.visualstudio.com/spaces/21/index.html – Andy Li-MSFT May 18 '18 at 06:40