Monday, September 10, 2007

Problems connecting to TFS.


Fiddler or other http proxy tool is running.

Shut them down or the bellow info may help:
Beginning with the December CTP, there is an optional registry setting that you can use to tell the Team Foundation client to bypass the proxy server without changing your IE settings.  In HKCU (per user) or HKLM (global), you can create the registry entry Software\Microsoft\VisualStudio\8.0\TeamFoundation\RequestSettings\BypassProxyOnLocal of type string with the value "true" to get the improved performance.

Client-side tracing enabled in the devenv.exe.config for the level higher than 2.

You may be able to connect to tfs by invoking the url in the browser or via sidekicks. But when connecting via VS you may get the following error message.

---------------------------
Microsoft Visual Studio
---------------------------
TF31002: Unable to connect to this Team Foundation Server: kara.
Team Foundation Server Url: http://kara:8080.
Possible reasons for failure include:
- The Team Foundation Server name, port number or protocol is incorrect.
- The Team Foundation Server is offline.
- Password is expired or incorrect.
For further information, contact the Team Foundation Server administrator.

I was not getting any stack trace information as in case of this link: http://manicprogrammer.com/cs/blogs/michaelruminer/archive/2007/07/13/windows-update-net-2-0-update-may-impact-team-system.aspx

That is why I decided to debug and came to the same exception:

-        $exception    {"Index and length must refer to a location within the string.\r\nParameter name: length"}    System.Exception {System.ArgumentOutOfRangeException}

Thrown in the line:
string str2 = request.RequestUri.Segments[1].Substring(0, 3);

of the following code:

private void TraceWebMethodRequest(WebRequest request)
{
    if (ProxyTracing.TraceInfo)
    {
        if (this.m_callStartTimes == null)
        {
            this.m_callStartTimes = new Dictionary<int, long>();
            this.m_timer = new Stopwatch();
            this.m_timer.Start();
        }
        this.m_callStartTimes[request.GetHashCode()] = this.m_timer.ElapsedMilliseconds;
        StackTrace trace = new StackTrace();
        string name = trace.GetFrame(3).GetMethod().Name;
        if (name.Equals("BeginInvoke", StringComparison.OrdinalIgnoreCase))
        {
            name = "{AsyncSharepoint}";
        }
        string str2 = request.RequestUri.Segments[1].Substring(0, 3);
        if (str2.Equals("sit", StringComparison.OrdinalIgnoreCase) || str2.Equals("_vt", StringComparison.OrdinalIgnoreCase))
        {
            str2 = "Wss";
        }
        Trace.WriteLine("Web method running: [" + request.RequestUri.AbsoluteUri + "] " + (name + "[" + str2 + "]"));
    }
}
which brought me to the following links that helped to resolve the problem:
http://manicprogrammer.com/cs/blogs/michaelruminer/archive/2007/07/13/windows-update-net-2-0-update-may-impact-team-system.aspx
http://support.microsoft.com/kb/936210

I didn't call to MS though, but just set the tracing level values to be less than 3:

<switches>
  <add name="TeamFoundationSoapProxy" value="2" />
  <add name="VersionControl" value="2" />
</switches>

Technorati Tags: ,
Post a Comment