我使用以下代码连接到TFS
TfsTeamProjectCollection server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(serverName));
server.EnsureAuthenticated();
工作正常。最近我们已经从本地TFS迁移到VSTS(在云端)。以上仍然有效,但已设置本地代理服务器以帮助加快我们的连接。我可以通过以下代码配置它:
var versionControlServer = server.GetService<VersionControlServer>();
versionControlServer.ConfigureProxy(proxyName);
这似乎第一次连接正常。但是,如果我重新启动我的应用程序,那就是'EnsureAuthenticated&#39;调用失败,异常:
Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: TF30063: You are not authorized to access mycorp.visualstudio.com\mycorp.
at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest()
at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout)
at Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs)
at Microsoft.TeamFoundation.Framework.Client.LocationWebService.Connect(Int32 connectOptions, Int32 lastChangeId, Int32 features)
at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.Connect(ConnectOptions connectOptions)
at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.EnsureConnected(ConnectOptions optionsNeeded)
at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.EnsureAuthenticated()
at Microsoft.TeamFoundation.Client.TfsConnection.EnsureAuthenticated()
为了让它再次运行,我发现如果我退出Visual Studio,我可以删除文件夹"C:\Users\MyUser\AppData\Local\Microsoft\Team Foundation\6.0\Cache"
。当我再次运行我的应用程序时,它将连接正常。但是,这种解决方法不会在生产中发挥作用。
如何使用代理连接并连接多次?
答案 0 :(得分:0)
将Microsoft.IdentityModel.Clients.ActiveDirectory 2.28.3 package安装到我的项目(控制台应用程序)后,它运行正常。