【问题标题】:Unable to connect to TFS 2010 programmatically by VS2015VS2015 无法以编程方式连接到 TFS 2010
【发布时间】:2016-09-02 16:55:08
【问题描述】:

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

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:

有解决问题的办法吗? 谢谢 卢卡

【问题讨论】:

  • 报错告诉你需要添加对Microsoft.VisualStudio.Services.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a的引用

标签: c# tfs visual-studio-2015


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-06-11
    • 2013-06-12
    • 2018-09-14
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多