ASP.NET-MVC and TFS: Getting TF30076 Error

2019-07-28 22:55发布

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

3条回答
可以哭但决不认输i
2楼-- · 2019-07-28 23:38

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().

查看更多
三岁会撩人
3楼-- · 2019-07-28 23:41

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.

查看更多
Rolldiameter
4楼-- · 2019-07-28 23:52

Some attempts at psychic debugging:

  • Are you passing a friendly name or a real, valid URI? If a friendly name, have you used Visual Studio or regedit or similar to initialize the URI mapping? (HKLM\Software\Microsoft\VisualStudio\xxx\TeamFoundation\Servers)
  • Is ASP running in a network context which requires a different URI to reach TFS (e.g. netbios name vs fully qualified domain name, different port...)
  • Are the proxy settings the same on the two machines? Firewall?
  • What credentials are you passing thru to the TeamFoundationServer constructor?
    • If none (as the sample code shows), what domain account is your App Pool running under?
    • Is the thread where you construct TeamFoundationServer running in an impersonated context? Have you verified impersonation is working the way you expect?
查看更多
登录 后发表回答