2012-10-02 7 views
5

私はTFS APIを使用してテスト計画を取得しようとしています。TFS API TestManagementServiceは常にnullを返します

TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://xxxxxxx:8080/tfs/DefaultCollection")); 

var service = (ITestManagementService)tfs.GetService(typeof(ITestManagementService)); 

変数 "service"は常にnullを返します。

あなたはどんな考えがありますか?

+0

tfs.GetService(typeof(WorkItemStore))はストアオブジェクトを返しますが、ItestManagementServiceはnullを返します。 – cerezza

答えて

2

おそらく、あなたは、Visual Studioのアセンブリの異なるバージョンを混合、参照アセンブリの異なるバージョンに対してリンクしていますか?例:

  • Microsoft.TeamFoundation.Client v11.0(VS 2012)
  • Microsoft.TeamFoundation.TestManagement.Client v12.0(VS 2013)

私はGetService<VersionControlServer>()が良い戻ってくる場合でも、GetService<ITestManagementService>()必ず返すヌルの同じ問題を抱えていました(非ヌル)値。

解決策はMSDN - VersionControlServer always returns nullで投稿されました。私はいくつかのv11.0(VS2012)およびv12.0(VS2013)アセンブリへの参照がありました。 v11.0へのすべての参照を変更すると、私のために修正されました。

4

Get Serviceコマンドを呼び出す前に、チームプロジェクトコレクションに認証されていることを確認してください。このコードスニペットは、私のために正しく動作:

TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("https://tfs.companyname.com/tfs/DefaultCollection")); 
tpc.EnsureAuthenticated(); 

ITestManagementService service = tpc.GetService<ITestManagementService>(); 
関連する問題