uri类未显示在系统名称空间中

时间:2018-08-08 18:49:30

标签: c# .net

我正在尝试使用.NET 4.5 Framework编译以下代码:

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版本,但仍然存在相同的问题,尽管如果选择.NET 4.0客户端配置文件时确实会出现,但是Microsoft命名空间中没有TeamFoundation类。

1 个答案:

答案 0 :(得分:0)

我解决了自己的问题,但我不明白为什么会这样。无奈之下,我使用.NET 4.5创建了另一个新项目,然后复制并粘贴了代码。它进行编译,并且Uri在对象浏览器中显示为类。我不知道这两个项目之间有什么区别。