2012-02-06 16 views
6

実行中のTFSサーバー用のワークアイテムストアに接続する2つの方法を試しました。試行Aは、構成サーバーに接続し、GetService<WorkItemStore>()メソッドを使用することでした。これは常にnullを返します。TFS 2010ワークアイテムストアにどのようにしっかり接続できますか?

試行Bは、TfsTeamProjectCollectionに接続し、GetService<WorkItemStore>()メソッドを使用するか、プロジェクトコレクションをWorkItemStoreコンストラクタに渡すことでした。試行Bでは、「エラーHRESULT E_FAILがCOMコンポーネントへの呼び出しから返されました」という例外が表示されます。私が見つけることができる唯一の情報はいくつかのアクセス許可の問題を示すようですが、プロジェクト全体のコレクションへの読み取りアクセス権を持つユーザーとして認証されていることを確認しました。

ここに私が...

public TfsConfigurationServer GetConfigurationServer() 
    { 
     Uri tfsUri = new Uri(configs.TfsUri); 
     TfsConfigurationServer server = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri, credProvider); 
     server.Authenticate(); 
     if (server.HasAuthenticated == false) 
      throw new InvalidOperationException("You can't authenticate against the tfs instance."); 
     return server; 
    } 

    public TfsTeamProjectCollection GetProjectCollectionInstance(string projectCollectionName) 
    { 
     Uri tfsUri = new Uri(configs.TfsUri + "/" + projectCollectionName);   
     TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri, credProvider); 
     collection.Authenticate(); 
     if (collection.HasAuthenticated == false) 
      throw new InvalidOperationException("You can't authenticate against the tfs instance."); 
     return collection; 
    } 

、ここでは私がWorkItemStore(問題を説明するために愚かなコード)を取得しようとしている方法です...私は接続してる方法です

public WorkItemProvider() 
    { 
     if (workItems == null) 
      workItems = ServerProvider.ServerInstance.GetService<WorkItemStore>(); 
     if (workItems == null) 
      workItems = ServerProvider.ProjectCollectionInstance.GetService<WorkItemStore>(); 
     if (workItems == null) 
      workItems = new WorkItemStore(ServerProvider.ProjectCollectionInstance); 
     if (workItems == null) 
      throw new NullReferenceException("Couldn't load work item store."); 
    } 

サーバーと同じドメインにはいませんが、ICredentialsProviderを持つドメインユーザーとして認証しており、そのユーザーとして認証されていることを確認しました。任意のポインタが役立つだろう。これは何が必要ない場合

+0

追加情報:Windowsの認証となりすましを使用して、ドメイン内のコンピュータで同じコードが正常に動作します。私はドメイン外からこれを行うことはできないと思いますか?私はVisual Studioからすることができますので、それは理にかなっていません。たとえ私がドメインにいなくてもドメインユーザーになりすますことができますか? – sonicblis

答えて

2

チェック:

using System; 
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.WorkItemTracking.Client; 

namespace GetsWorkItem 
{ 
    class Program 
    { 
     static void Main() 
     { 
      TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://<TFS>:8080/tfs/<COLLECTION>")); 
      WorkItemStore workItemStore= (WorkItemStore) teamProjectCollection.GetService(typeof (WorkItemStore)); 

      WorkItem workItem = workItemStore.GetWorkItem(1234); 
     } 
    } 
} 
+1

コンソールアプリケーションで動作します(認証を追加すると)、Webアプリケーションでは動作しません。私の質問でBと同じエラー。 – sonicblis

+0

申し訳ありませんが、あなたのためにうまくいかなかった – pantelif

0

私はthis articleは、あなたの質問に答えることができるかもしれないと考えています。

<?xml version="1.0"?> 
<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 
</configuration> 
次のように追加することで、

System.TypeInitializationException: The type initializer for ‘Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore’ threw an exception. —> System.IO.FileLoadException: Mixed mode assembly is built against version ‘v2.0.50727′ of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

修正は、単純なweb.configファイルの変更である:それはあなたがわずかに異なる方法であなたのWorkItemStoreをインスタンス化した場合、あなたは別の例外を取得しますと言っています

希望します。同じエラーが発生したときに私のために働いた。

関連する問題