如何成功连接到 TFS 2010 工作项存储?
我尝试了两种连接到我们正在运行的 TFS 服务器的工作项存储的方法。尝试 A 是连接到配置服务器并使用 GetService
尝试 B 是连接到 TfsTeamProjectCollection 并使用 GetService
这是我的连接方式...
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 的域用户,并且我已确认我已通过该用户的身份验证。任何指示都会有帮助。
I've tried two ways of connecting to the workitemstore for the TFS server we're running. Attempt A was to connect to the configuration server and use GetService<WorkItemStore>()
method. This always returns null.
Attempt B was to connect to the TfsTeamProjectCollection and use the GetService<WorkItemStore>()
method or pass the project collection into the WorkItemStore constructor. On attempt B, I get an exception stating "Error HRESULT E_FAIL has been returned from a call to a COM component." The only info I can find on that seems to indicate some permissions problem, but I've confirmed I'm authenticated as a user with read access to the whole project collection and I connect and meddle appropriately via VS 2011 dev preview.
Here's how I'm connecting...
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;
}
and here's how I'm trying to get the WorkItemStore (silly code to illustrate the problem)...
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.");
}
I'm not on the same domain as the server, but I'm authenticating as a domain user with an ICredentialsProvider and I've confirmed I'm authenticated as that user. Any pointers would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查这是否满足您的需要:
Check if this does what you need:
我相信这篇文章也许能够回答你的问题。它表示,如果您以稍微不同的方式实例化 WorkItemStore,您将得到不同的异常:
System.TypeInitializationException:“Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore”的类型初始值设定项引发异常。 —> System.IO.FileLoadException:混合模式程序集是针对运行时版本“v2.0.50727”构建的,如果没有附加配置信息,则无法在 4.0 运行时中加载。
该修复是一个简单的 web.config 更改,通过添加以下内容:
希望这有帮助!当我遇到同样的错误时为我工作。
I believe this article might be able to answer your question. It says that if you instantiate your WorkItemStore in a slightly different way, you'll get a different exception:
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.
The fix is a simple web.config change, by adding the following:
Hope this helps! Worked for me when I was getting the same error.