c# - uri 类未显示在系统命名空间中
问题描述
我正在尝试使用 .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 类。
解决方案
我解决了自己的问题,但我不明白为什么它会起作用。无奈之下,我使用 .NET 4.5 创建了另一个新项目,然后复制并粘贴了代码。它编译并且 Uri 在对象浏览器中显示为一个类。我不知道这两个项目之间有什么区别。
推荐阅读
- azure-devops - 将文件直接上传到不属于部署的 Azure 应用服务
- stm32 - 如何从中断例程将数据发送到 EEPROM
- java - 当我尝试测试使用从 Tomcat 中的 JNDI 连接轮询获得的连接的 Dao 方法时,我得到 NoInitialContextException
- python - python .loc 混乱。帮助使用 str.endswith
- r - 热图(geom_tile)的调整?
- c# - 如何在流利的NHibernate中创建外键关系而不持有对父实体的引用
- arduino - 带有 Esp32 w5500 以太网模块的软件在 Mqtt 存在重新连接问题
- mysql - 预期输入结束,但在连接中使用 UNNEST 时获得关键字“ON”(bigQuery)
- spring-boot - Spring websocket jwt身份验证
- d3.js - 将 Flash 坐标转换为 GeoJSON