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

时间:2016-09-01 10:17:58

标签: c# tfs visual-studio-2015

我无法从简单的C#控制台应用程序连接到Team Foundation Server 2010(TFS)。 我的控制台应用程序将.Net Framework 4.5作为目标框架,并在VS2015中打开。 在项目中,我使用Nuget引用了TFS API,在下面的图片中,您可以看到程序集。 Project_Configuration 这是简单的代码

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));
      }
}

返回的异常是:

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:

在我引用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:

有什么想法解决这个问题吗? 谢谢 卢卡

1 个答案:

答案 0 :(得分:0)

在VS2015中,您可以在list.stream().mapToInt(o->o.field).sum(); 中找到dll,尝试添加路径中的dll。