Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 以编程方式授权tfs时出错_C#_Tfs - Fatal编程技术网

C# 以编程方式授权tfs时出错

C# 以编程方式授权tfs时出错,c#,tfs,C#,Tfs,我有当地的tfs 2012。在VisualStudio2012上,使用c#,我编写了以编程方式连接到tfs服务器的程序。但我有一个错误: {“TF30063:您无权访问。”}System.Exception{Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException} 我的代码: Uri collectionUri = new Uri("http://server:8080/tfs"); NetworkCredential

我有当地的tfs 2012。在VisualStudio2012上,使用c#,我编写了以编程方式连接到tfs服务器的程序。但我有一个错误:

{“TF30063:您无权访问。”}System.Exception{Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException}

我的代码:

Uri collectionUri = new Uri("http://server:8080/tfs");
NetworkCredential netCred = new NetworkCredential("login","password");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(collectionUri, netCred);
teamProjectCollection.EnsureAuthenticated();//throw error here
你能帮我纠正这个错误吗

另外,我尝试用这种方式连接,但我有相同的错误:

var projectCollection = new TfsTeamProjectCollection(
new Uri("http://myserver:8080/tfs/DefaultCollection"), 
new NetworkCredential("youruser", "yourpassword"));

projectCollection.Connect(ConnectOptions.IncludeServices);
这样:

Uri collectionUri = new Uri("http://server:8080/tfs/DefaultCollection");
NetworkCredential netCred = new NetworkCredential("login","password","Server.local");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(collectionUri, netCred);
teamProjectCollection.EnsureAuthenticated();
希望对你有帮助

var tfsCon = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://server:8080/tfs"));
tfsCon.Authenticate();
var workItems = new WorkItemStore(tfsCon);
var projectsList = (from Project p in workItems.Projects select p.Name).ToList();

如果此处失败,则需要在App.config中配置以设置默认代理:

<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <system.net>
      <defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
   </system.net>
</configuration>


您是否尝试在uri中使用集合名称。。。Uri collectionUri=新Uri(“);如果您在域中,则应使用域名作为凭据….NetworkCredential netCred=新的NetworkCredential(“登录”、“密码”、“域名”);您能与我们分享一下解决您问题的选项吗?我在尝试使用与您的原始帖子几乎完全相同的代码连接到我们的内部TFS服务器时也遇到了TF30063错误。
<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <system.net>
      <defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
   </system.net>
</configuration>