簡體   English   中英

VS2015無法以編程方式連接到TFS 2010

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

我無法通過簡單的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:

有解決問題的主意嗎? 謝謝盧卡

在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