0

I tried connecting to TFS using C# . Here is my code :

         Uri url = new Uri("http://serverpath/DefaultCollection");

        NetworkCredential nc = new NetworkCredential("ID", "Password", "Domain");

        TfsTeamProjectCollection coll = new TfsTeamProjectCollection(url, nc);

        coll.EnsureAuthenticated();

I get the following error :

 The underlying connection was closed: An unexpected error occurred on a receive.

Inner Exception : {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."}

Any solutions about what could be the issue ??

CodeNinja
  • 3,188
  • 19
  • 69
  • 112
  • possible duplicate of [Unable to read data from the transport connection : An existing connection was forcibly closed by the remote host](http://stackoverflow.com/questions/5420656/unable-to-read-data-from-the-transport-connection-an-existing-connection-was-f) – Martin Gemme Nov 14 '14 at 21:09
  • Check the server log. – CodeCaster Nov 14 '14 at 21:11
  • hmm ! I cant check the server log .. Dont have access to it. Do you know if the server path needs a port number as well ? – CodeNinja Nov 14 '14 at 21:12
  • 2
    In my code, I've always included the port. Not sure if it's required. Also, typical VS 2010 paths are "http://server:8080/tfs/DefaultCollection". – Michael Nov 14 '14 at 21:28
  • Thats what the issue was "path" ! It works now . Thanks. Upvoted – CodeNinja Nov 14 '14 at 23:11
  • @Michael Add your comment as the answer so we can properly close the question – Richard Banks Nov 17 '14 at 09:18

1 Answers1

1

It looks like you're missing the port number, and the /tfs in the URI.

Typically TFS 2010 URIs are http://server:8080/tfs/DefaultCollection.

Richard Banks
  • 12,456
  • 3
  • 46
  • 62
Michael
  • 1,556
  • 13
  • 25