0

I am trying to automate the TFC using Microsoft.TeamFoundation library using C#.net but I am unable to connect to tfs using C#.net code it shows error

        string tfsUrl = "http://xx.xx.xx.xx:8080/tfs";
        NetworkCredential netCred = new NetworkCredential("userid","password");
        BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
        TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
        tfsCred.AllowInteractive = false;
        TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tfsUrl),tfsCred);
        tpc.Authenticate();

An unhandled exception of type 'Microsoft.TeamFoundation.TeamFoundationServiceUnavailableException' occurred in Microsoft.TeamFoundation.Client.dll

Additional information: TF400324: Team Foundation services are not available from the server.

Technical information (for administrator):

TF31002: Unable to connect to this Team Foundation Server: http://xx.xx.xx.xx:8080/tfs.

Team Foundation Server Url: http://xx.xx.xx.xx:8080/tfs.

Possible reasons for failure include:

  • The name, port number, or protocol for the Team Foundation Server is incorrect.

  • The Team Foundation Server is offline.

  • The password has expired or is incorrect.

For further information, contact the Team Foundation Server administrator.

but when I use same tfs URL, Userid and password with web browser like chrome/IE it connects me without any issue. Please help me what I am doing wrong.

Neeraj Kumar Gupta
  • 2,157
  • 7
  • 30
  • 58

1 Answers1

0

First, Checks this: 1. Check if maybe the connection is https instead of http 2. Check if you need to add an project instance (collection) to connect at the en of the Url and you can access to this collection, for example if you have a project called xxx, the url to connect will be: string tfsUrl = "http://xx.xx.xx.xx:8080/tfs/xxx";

If doesn't work with this changes I think it's a security port or security account permission.

Hope this help