简体   繁体   English

VS2015无法以编程方式连接到TFS 2010

[英]Unable to connect to TFS 2010 programmatically by VS2015

I'm unable to connect to Team Foundation Server 2010 (TFS) from a simple C# Console Application. 我无法通过简单的C#控制台应用程序连接到Team Foundation Server 2010(TFS)。 My Console Application has .Net Framework 4.5 as Target Framework and is opened into VS2015. 我的控制台应用程序将.Net Framework 4.5作为目标框架,并已在VS2015中打开。 In the project I referenced the TFS API with Nuget, in the pic below you can see the assemblies. 在项目中,我使用Nuget引用了TFS API,在下面的图片中,您可以看到程序集。 项目配置 And this is the simple code 这是简单的代码

using Microsoft.TeamFoundation.Client;
using System;
using System.Configuration;
using System.Data;
using System.IO;

namespace FindWorkItemChangesetDetails
{
    public class Program
    {
        static void Main(string[] args)
        {
            string TfsServer = "http://xx.xxx.xxx.xx:8080/tfs";

            ////Initialize TFS Server object
            TfsConfigurationServer configurationServer = 
                TfsConfigurationServerFactory.GetConfigurationServer(new Uri(TfsServer));
      }
}

The exception returned is: 返回的异常是:

System.IO.FileNotFoundException was unhandled
  FileName=Microsoft.VisualStudio.Services.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  FusionLog==== Informazioni sullo stato di preassociazione ===
REG: DisplayName = Microsoft.VisualStudio.Services.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
REG: Appbase = file:///C:/Sviluppo/Tool/FindWorkItemChangesetDetails/bin/Debug/
REG: PrivatePath iniziale = NULL
Assembly chiamante: Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
REG: l'associazione ha origine nel contesto di caricamento di default.
REG: utilizzo del file di configurazione dell'applicazione: C:\Sviluppo\Tool\FindWorkItemChangesetDetails\bin\Debug\FindWorItemChangesetDetails.vshost.exe.config
REG: utilizzo del file di configurazione host: 
REG: utilizzo del file di configurazione computer da C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
REG: riferimento post-criteri: Microsoft.VisualStudio.Services.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
REG: tentativo di download del nuovo URL file:///C:/Sviluppo/Tool/FindWorkItemChangesetDetails/bin/Debug/Microsoft.VisualStudio.Services.Common.DLL.
REG: tentativo di download del nuovo URL file:///C:/Sviluppo/Tool/FindWorkItemChangesetDetails/bin/Debug/Microsoft.VisualStudio.Services.Common/Microsoft.VisualStudio.Services.Common.DLL.
REG: tentativo di download del nuovo URL file:///C:/Sviluppo/Tool/FindWorkItemChangesetDetails/bin/Debug/Microsoft.VisualStudio.Services.Common.EXE.
REG: tentativo di download del nuovo URL file:///C:/Sviluppo/Tool/FindWorkItemChangesetDetails/bin/Debug/Microsoft.VisualStudio.Services.Common/Microsoft.VisualStudio.Services.Common.EXE.

  HResult=-2147024894
  Message=Impossibile caricare il file o l'assembly 'Microsoft.VisualStudio.Services.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' o una delle relative dipendenze. Impossibile trovare il file specificato.
  Source=Microsoft.TeamFoundation.Client
  StackTrace:
       in Microsoft.TeamFoundation.Client.TfsClientCredentials.LoadCachedCredentials(String featureRegistryKeyword, Uri serverUrl, Boolean requireExactMatch, Boolean allowInteractive, String registryRootPath, Boolean useWOW6432Hive)
       in Microsoft.TeamFoundation.Client.TfsClientCredentialsCache.GetCredentials(String featureRegistryKeyword, Uri uri)
       in Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory.GetConfigurationServer(Uri uri)
       in FindWorkItemChangesetDetails.Program.Main(String[] args) in C:\Sviluppo\Tool\FindWorkItemChangesetDetails\Program.cs:riga 16
       in System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       in System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       in System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       in System.Threading.ThreadHelper.ThreadStart()
  InnerException:

After I referenced the Microsoft.Visual Studio.Services.Common I got this error 在我引用Microsoft.Visual Studio.Services.Common后,出现此错误

System.TypeLoadException was unhandled
  HResult=-2146233054
  Message=Impossibile caricare il tipo 'Microsoft.TeamFoundation.Common.Internal.RegistryAccessMask' dall'assembly 'Microsoft.TeamFoundation.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
  Source=Microsoft.TeamFoundation.Client
  TypeName=Microsoft.TeamFoundation.Common.Internal.RegistryAccessMask
  StackTrace:
       in Microsoft.TeamFoundation.Client.CredentialsCacheManager..ctor()
       in Microsoft.TeamFoundation.Client.TfsClientCredentials.LoadCachedCredentials(String featureRegistryKeyword, Uri serverUrl, Boolean requireExactMatch, Boolean allowInteractive, String registryRootPath, Boolean useWOW6432Hive)
       in Microsoft.TeamFoundation.Client.TfsClientCredentialsCache.GetCredentials(String featureRegistryKeyword, Uri uri)
       in Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory.GetConfigurationServer(Uri uri)
       in FindWorkItemChangesetDetails.Program.Main(String[] args) in C:\Sviluppo\Tool\FindWorkItemChangesetDetails\Program.cs:riga 16
       in System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       in System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       in System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       in System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Any idea to fix the problem? 有解决问题的主意吗? Thank you Luca 谢谢卢卡

在VS2015中,您可以在C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer这些dll,尝试从路径中添加这些dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM