The problem in your code is, that the TfsTeamProjectCollection
does not fit to your path, because you never set the Collection name (should be something like @"http://MyServer:8080/tfs/DefaultCollection").
I never did a checkout by using the API, but I did a checkin starting like this:
WorkspaceInfo wi = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory);
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(wi.ServerUri);
VersionControlServer versionControlServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
Workspace workSpace = versionControlServer.GetWorkspace(wi);
As you can see, I search the TeamCollection by using my workspace and not setting it independent. Doing it this way, you will get the right VersionControlServer
to do your checkout.
The difference by using the tf.exe tool is, that you run it in your local workspace, so the tool knows to which item it is linked in TFS and to which Collection.