我試過兩種方式連接到我們正在運行的TFS服務器的workitemstore。嘗試A將連接到配置服務器並使用GetService<WorkItemStore>()
方法。這總是返回null。如何成功連接到TFS 2010 workitem商店?
嘗試B連接到TfsTeamProjectCollection,並使用GetService<WorkItemStore>()
方法或將項目集合傳遞給WorkItemStore構造函數。在嘗試B上,我收到一個異常,指出「錯誤HRESULT E_FAIL已從調用COM組件返回。」我能找到的唯一信息似乎表明有一些權限問題,但我已確認我是通過對整個項目集合的讀取權限進行身份驗證的,並且我通過VS 2011 dev預覽進行了適當的連接和干預。
這裏是我如何連接?
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作爲域用戶進行身份驗證,並且我確認我已通過該用戶的身份驗證。任何指針都會有幫助。
附加信息:相同的代碼在我們的域中使用Windows身份驗證和模擬的計算機上正常工作。我想我不能從域外做到這一點?我可以從Visual Studio中,所以沒有任何意義。也許如果我可以冒充域用戶,即使我不在域上? – sonicblis 2012-02-07 00:23:57