28

Just started up Visual Studio 2012 and opened my solution which is in source control with Team Foundation Server 2012 Express and encountered this, any ideas? Can't get latest, can't check in, everything appears checked out :( Basically my workspace is unusable right now.

TF400018: The local version table for the local workspace MY-PC;My User could not be opened. The workspace version table contains an unknown schema version.

There is only one post I could find on the net, and the answers are pretty vague.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
GONeale
  • 26,302
  • 21
  • 106
  • 149

12 Answers12

20

I had the same issue, and I just fixed it on mine.
If you don't mind re-map all your projects, you can try follow:

  • Click the box in "Workspace".
  • Click on "Workspaces".
  • Delete the workspace profile you're currently using
  • Re-connect to TFS open "Source Control"



Be aware that you may lose all your TFS mappings, you may need to re-map all your projects from TFS. Backup your changes that not checked in yet.

cycle6
  • 201
  • 1
  • 2
  • 1
    Visual Studio hung when I tried to do this, but amazingly after I killed it from task manager and restarted, the workspace (which was still there) started working correctly again. – John Sibly Jan 15 '14 at 13:35
  • 3
    Worked for me! Made a backup of my workspaces (simple zip file) and tried this solution. After re-mapping the projects to exact same folders as before and retrieving the files from TFS, TFS asked to overwrite the local files which where changed compared to the files in TFS. Choose "Keep local files" and all is working correctly again. (With your local changes) – pkmelee337 Apr 03 '14 at 09:19
  • 8
    "Click the box in "Workspace" doesn't describe where to find this "box". – James Madison Jun 06 '16 at 18:05
17

cycle6 is correct, but it isn't clear that you will not lose your pending check-in list if you follow some additional steps.

  1. Click the box labelled "Workspace".
  2. Click on "Workspaces".
  3. Delete the corrupt workspace profile, accepting the warning.
  4. Re-connect to TFS and open "Source Control Explorer"
  5. Create a new workspace
  6. One by one, map your projects to the same folder as before
  7. You will be presented with a list of conflicts, where you have matching writable files in the folder already.
  8. Choose "Keep local copy" for each file you had checked out before, and "Take Server Version" for any files changed by other members of the team that you didn't have the latest version for. This might take a while depending on the length of the list, but it is worth comparing versions for any file you are unsure of.

You will be left with your solution and all pending items marked as checked out, with your work preserved.

Rob King
  • 1,131
  • 14
  • 20
  • This worked for me, but I also had to restart visual studio(2017) because I was getting "cannot access a disposed object" errors – jazza1000 Jan 24 '18 at 09:11
11

I did the following steps and it solved the issue:

  1. deleted the hidden folder named $tfs and then
  2. in the Visual Studio, Solution Explorer: Right click on the solution node > the Source Control > Get Specific version > latest version
A-Sharabiani
  • 17,750
  • 17
  • 113
  • 128
10

If you already have multiple instances of Visual Studio open.

  1. Close all of them . [in some cases you need to log out from windows & log back in OR restart ]

  2. Rename the $tf folder with any other name (eg. $tft)

  3. Start Visual Studio, to see your issue fixed. :)

Hope this helps.

B Bhatnagar
  • 1,706
  • 4
  • 22
  • 35
  • This 'lost' my pending changes. They weren't lost, but not in my pending changes list – Matt Evans Jul 17 '18 at 12:59
  • 4
    Copying the pendingchanges.tf1 and pendingchanges.tfb files from the old directory to the new one resolved this problem – Matt Evans Jul 17 '18 at 13:09
  • This seems to have worked fairly well. Rename $tf folder and then copy back pendingchanges* files. No need do do any remapping, but VS does lose track of which sources have been downloaded. One thing none of the answers here mention is where this `$tf` folder is. It's in the root of the workspace folder on the file system. – JLRishe Oct 16 '20 at 06:10
5

Sometimes this happens when you are running out of disk space. Try to see if you have very low space, eg. < 10 MB.

If that so, try to clean up your windows Temp folder. See if that solve this issue

esasongko
  • 96
  • 1
  • 2
2

It's a misleading message to an extent. What has happened is that the internal data structures of the workspace have become corrupt. The ends up as the code (in the tf command, Visual Studio, et al.) to load those data structures failing to load from the relevant files, which becomes an error about a schema version problem.

In the case that I experienced, this was because the machine hosting the workspace ran out of disc space while doing operations upon the workspace of various kinds (check-outs, check-ins, adding pending changes — it was actually a bunch of workspaces being used by TFS 2017 build agents and multiple active builds). This corrupted parts of the data that are held in the files under the hidden $tf subdirectory (it always being a local workspace on a TFS 2017 build agent), because source control wasn't able to rewrite/extend these files.

Other answers here discuss partly retaining some of the files, based upon more specific knowledge of what has not been corrupted (such as preserving the internal files storing pending changes if one wasn't creating any pending changes), but the basic idea is that one needs to reset all of the stuff in $tf to a sane state of some kind.

In my case, I had the disadvantage of multiple potential causes and no consistent knowledge of which parts of $tf were corrupted, but I conversely had some advantages:

  • It being a TFS build, arranged to build from the build agent's s (source) directory into its a (artifact staging) and b (binaries) directories, there were not masses of non-source-controlled object and other files in the workspace (which is the s directory) that would have ended up as pending additions.
  • There were not any pending changes (to actual source files) worthwhile to preserve. I could afford to lose all information about source files, and indeed all current locally-stored information about the workspace, and simply run the build again with a fresh sane and largely unpopulated workspace. I did not even need to restore source files and directories for the whole workspace, as the first task in any TFS ("vNext") build is a "Get Sources" task that uses (variously) tf vc scorch, tf vc undo, and tf vc get to check out the right source version.

So simply, in Developer PowerShell (Visual Studio being installed on the build machine):

  1. Remove-Item -Recurse -Force 'X:\Agents\07\_work\1138\s'
  2. tf vc get 'X:\Agents\07\_work\1138\s'

(Note that one can always get at the tf command in some way on a TFS build machine. Every build agent has a local helper copy of tf.exe and its ancillary DLLs in its VSTS "OM" subdirectory.)

I possibly could have omitted the tf vc get step, but having had trouble with "Get Sources" in the past I do not trust it to robustly cope with arbitrary manual external alterations, such as no s directory when the build isn't configured to outright delete that entire directory itself (as it can be but was not here). For the same reason, Microsoft's own "agent maintenance" (another way to clean things up) is quite dodgy, and ends up leaking workspaces on the TFS server (which I have raised a bug with Microsoft about).

JdeBP
  • 2,127
  • 16
  • 24
1

There is simple workaround. Remove local mapping to folder where is the sources (Advanced -> Remove Mapping, or just rename or delete mapped folder. After that you will be able to connect to tfs. Download the project again.

Vasiliy Mazhekin
  • 688
  • 8
  • 24
1

enter image description hereIf you already have multiple tfs instances of Visual Studio open.

1.) Open File -> Source Control -> Manage Workspaces 2.) Delete all tfs map 3.) Then select folder maps

1

For the same issue in eclipse: Find the folder $tf and delete it. You will find the $tf folder in the workspace directory. If not then search for the $tf folder. Once you have found it, delete it.

Jijo Mathew
  • 322
  • 2
  • 15
1

In my case, none of the other answers helped - the problem was occurring on a machine that didn't have Visual Studio and no matter how I tried to get rid of the bad workspace data it never worked. After working with procmon a bit, I discovered another critical folder that might be the source of this error: C:\Users\All Users\Microsoft Team Foundation Local Workspaces\ (it might also be under C:\ProgramData (on my system, 'All Users' is a symlink to that folder, but not sure if this is typical.) In this folder there are sub-folders named like guids that contain some other folders, one per workspace it appears. In my case, some of the data in these folders was old and some was corrupt. Once I deleted the bad workspace folders, all my problems disappeared. You might also want to delete the Cache folder as identified in the comments of this post, but that didn't help me (didn't seem to hurt though, either.)

Michael Bray
  • 14,998
  • 7
  • 42
  • 68
0

Alternatively, you could just backup your current workspace to a different location, re-create your workspace, and copy the files back that you had made changed to. VS should detect the newest files and automatically check out these files allowing you to check in the newer versions that you copied back from your backup.

ganjeii
  • 1,168
  • 1
  • 15
  • 26
0

What worked for me is, delete the local folder(s), restart your machine, then map the projects again. Any pending changes you have just save them somewhere else temporarily.