我正在尝试使用.NET 4.5框架编译以下代码:
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Discussion.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
class CodeReview
{
public List<CodeReviewComment> GetCodeReviewComments(int workItemId)
{
List<CodeReviewComment> comments = new List<CodeReviewComment>();
Uri tfsuri = new Uri(MYURL);
TeamFoundationDiscussionService service = new TeamFoundationDiscussionService();
service.Initialize(new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(tfsuri));
IDiscussionManager discussionManager = service.CreateDiscussionManager();
IAsyncResult result = discussionManager.BeginQueryByCodeReviewRequest(workItemId, QueryStoreOptions.ServerAndLocal, new AsyncCallback(CallCompletedCallback), null);
var output = discussionManager.EndQueryByCodeReviewRequest(result);
foreach (DiscussionThread thread in output)
{
if (thread.RootComment != null)
{
CodeReviewComment comment = new CodeReviewComment();
comment.Author = thread.RootComment.Author.DisplayName;
comment.Comment = thread.RootComment.Content;
comment.PublishDate = thread.RootComment.PublishedDate.ToShortDateString();
comment.ItemName = thread.ItemPath;
comments.Add(comment);
}
}
return comments;
}
static void CallCompletedCallback(IAsyncResult result)
{
// Handle error conditions here
}
public class CodeReviewComment
{
public string Author { get; set; }
public string Comment { get; set; }
public string PublishDate { get; set; }
public string ItemName { get; set; }
}
}
Visual Studio编译器报告“找不到类型或命名空间' Uri‘”,并且当我在对象浏览器中展开系统命名空间时,它没有列出任何Uri类。我已经尝试了其他几个版本的.NET,仍然有同样的问题,尽管如果我选择Microsoft4.0客户端配置文件,但没有任何TeamFoundation类出现在.NET命名空间中,它确实会出现。
发布于 2018-08-09 04:06:31
我解决了我自己的问题,但我不明白为什么它会起作用。无奈之下,我使用.NET 4.5创建了另一个新项目,并复制并粘贴了代码。它进行了编译,Uri在对象浏览器中显示为一个类。我不知道这两个项目有什么不同。
https://stackoverflow.com/questions/51753737
复制相似问题