On one of my machines, I get a return value of null from any GetLocalWorkspaceInfo
call. I have isolated to problem to where it even fails for this simple program:
namespace WorkstationTest
{
using Microsoft.TeamFoundation.VersionControl.Client;
class Program
{
static void Main()
{
string workspaceLocalPath = @"C:\Dev";
var info = Workstation.Current
.GetLocalWorkspaceInfo(workspaceLocalPath);
// info is always null here
}
}
}
What I have already checked:
The exact same code works on my other machine the way it should.
I have verified that I have a workspace at
C:\Dev
I have created a new workspace and in a different directory and changed the
workspaceLocalPath
variable in the code to match.I have consulted the documentation which states that the return value will be null
if the path is not in a workspace
. From the above image, the path should be in a workspace.
Yet, everything seems to suggest this should work. Is there anything I could be missing?
When executing
tf workspaces
(on my computer) in the Visual Studio 2010 command prompt it saysNo workspace matching * found on this computer
, but when executing the same command in Visual Studio 2012 it returns back all my expected workspaces.The issue can be resolved by doing any of the following:
Reference the version of the
Microsoft.TeamFoundation.VersionControl.Client
dll that was connected with Visual Studio 2012 instead of the dll connected with Visual Studio 2010.Open Visual Studio 2010 and connect it to TFS to where it will create the workspaces for Visual Studio 2010
Simply run with the tricks.
Nothing is going to work properly without a proper DLL reference. The below had fixed the same issue i had for 5 days as it was screwing my time up.
Place the below DLL's in the bin folder of your project and give a reference to the whole solution for all the DLL's. If any error comes up like 'Reference could not be given' ignore it and skip that DLL from giving reference instead just place also the error creating DLL in bin folder which the project will automatically take during build
The above dll's can be found in the below path if the System is installed with MTM or TFS
Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer
After migrating from TFS2013 to TFS2017 in the company I work for I had the same problem with Workstation.Current.GetLocalWorkspaceInfo.
What worked for me is a call to
Workstation.EnsureUpdateWorkspaceInfoCache
:I added the above code lines to the constructor of my TFS proxy class that uses GetLocalWorkspaceInfo.
I know this is an old post, but just like to share the workaround that we have, by using VersionControlServer.QueryWorkspaces to query all the workspaces for the user on his/her machine.
I had this issue recently (today) using Visual Studio 2017, plus several other versions installed and a number of local workspaces.
I ended up updating the 'Team Foundation Server Client' NuGet package to the latest version (
15.x
) through the 'Manage NuGet Packages' menu and that fixed it.I did also remove the existing project references first but that part might depend on what you need.
In my case, this issue occurred because of VersionControl.config file put under TFS cache (C:\Users\DeepakR\AppData\Local\Microsoft\Team Foundation\5.0\Cache\Volatile\0cb76a25-2556-4bd6-adaa-5e755ac07355_http)folder goes for a toss i.e. the configured workspace information weren't available as expected.
So, It basically needs a refresh of VersionControl.config file. Auto Refersh happens when Visual Studio gets loaded again i.e. it pulls the configured workspace information from Server and updates the config file or even if we execute tf command utility (tf.exe workspaces /collection:TFSURL)
Microsoft.TeamFoundation.VersionControl.Client's(v12.0.0.0) Workstation class has a function EnsureUpdateWorkspaceInfoCache which will do the same trick
VersionControlServer vcs = (VersionControlServer)tpc.GetService(typeof(VersionControlServer)); Workstation.Current.EnsureUpdateWorkspaceInfoCache(vcs, Environment.UserName);
https://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.workstation.ensureupdateworkspaceinfocache(v=vs.120).aspx
Hope the suggestion helps to resolve the issue.