When I try to create a Microsoft.TeamFoundation.Client.TeamFoundationServer object in the HomeController of my MVC application, I receive the following error:
TF30076: The server name {TfsServerName} provided does not correspond to a server URI that can be found. Confirm that the server name is correct.
I am using Windows Authentication for the MVC app, so the Controller.User property is populated as my domain login {domain\username}.
When I debugged using the Visual Studio Development Server, the code worked fine. After I began using a virtual directory in IIS, the execution of the code began returning the aforementioned error.
I am using Visual Studio / TFS 2008 (v9.0), Windows XP environment, and ASP.NET MVC 1.0.
Exception:
Microsoft.TeamFoundation.TeamFoundationInvalidServerNameException: TF30076: The server name {xxxx} provided does not correspond to a server URI that can be found. Confirm that the server name is correct. at Microsoft.TeamFoundation.Client.TeamFoundationServer.GetUriForName(String name) at Microsoft.TeamFoundation.Client.TeamFoundationServer.get_Uri() at Microsoft.TeamFoundation.Client.CheckAuthenticationProxy..ctor(TeamFoundationServer server) at Microsoft.TeamFoundation.Client.TeamFoundationServer.Authenticate(Boolean useProvider, ICredentialsProvider provider) at Microsoft.TeamFoundation.Client.TeamFoundationServer.Authenticate() at Portal.TfsHelper.AuthenticateTfsServer() in D:\Portal\Portal\Models\TfsHelper.cs:line 99
Code throwing the exception is shown below:
try
{
// authenticate before using tfs server
//TfsServer is created using the following: TfsServer = new TeamFoundationServer("server-name");
if (!TfsServer.HasAuthenticated)
{
TfsServer.Authenticate();
_hasAuthenticated = true;
}
}
catch (Exception ex)
{
#warning: temporary error handling for TFS authentication
String exString = ex.ToString();
throw new Exception(ex.Message, ex.InnerException);
}
Any thoughts on why this is happening?
Exception appearing after calling "RegisteredServers.AddServer("server-name", "http://server-name:8080");":
System.Security.SecurityException: Requested registry access is not allowed. at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at Microsoft.TeamFoundation.Client.RegisteredServers.OpenCurrentUser(Boolean writable, Boolean shouldCreate) at Microsoft.TeamFoundation.Client.RegisteredServers.AddServer(String serverFriendlyName, String serverUrl) at Portal.Controllers.HomeController..ctor() in D:\Portal\Portal\Controllers\HomeController.cs:line 42 The Zone of the assembly that failed was: MyComputer
Most likely, the server name {TfsServerName} provided does not correspond to a server URI that can be found. You should confirm that the server name is correct.
Come on, do you think it's lying to you? That it found the server but decided you don't deserve to use it? Most likely, you're not passing it the server name you think you are. Stop in the debugger and make sure it's the same string you get when you test in the Development Server.
Also, did you receive an error, or was it an exception? If it was an exception, then please catch the exception, then post the entire exception by posting the result of ex.ToString().
The error that I was getting is "Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\TeamFoundation\Servers' is denied. System.UnauthorizedAccessException: Access to the registry key "
It worked once I added the TFS server in the Visual Studio. Don't know why.. but just adding my answer here so that it might help someone later.
Some attempts at psychic debugging: