Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 通过API创建新工作项时,无法在TFS中获取AssignedTo字段的有效用户列表_Visual Studio 2010_Tfs_Tfs Workitem_Tfs Sdk - Fatal编程技术网

Visual studio 2010 通过API创建新工作项时,无法在TFS中获取AssignedTo字段的有效用户列表

Visual studio 2010 通过API创建新工作项时,无法在TFS中获取AssignedTo字段的有效用户列表,visual-studio-2010,tfs,tfs-workitem,tfs-sdk,Visual Studio 2010,Tfs,Tfs Workitem,Tfs Sdk,您好,我正在尝试通过TFSAPI创建新的工作项,这是我在下面使用的方法,用于获取可分配工作项的有效用户列表。不知怎的,它在validUserSids行上给了我一个空引用异常。有人知道这里出了什么事吗 private string[] TFSUsers(string server) { // Get a Reference to Team Foundation Server. TeamFoundationServer tfs = tfsdata.GetTFS

您好,我正在尝试通过TFSAPI创建新的工作项,这是我在下面使用的方法,用于获取可分配工作项的有效用户列表。不知怎的,它在validUserSids行上给了我一个空引用异常。有人知道这里出了什么事吗

private string[] TFSUsers(string server)
    {
        // Get a Reference to Team Foundation Server.
        TeamFoundationServer tfs = tfsdata.GetTFS(server);
        // Get a reference to Group Security Service.
        IGroupSecurityService gss = (IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService));
        // Resolve to SIDs
        Identity validUserSids = gss.ReadIdentity(SearchFactor.AccountName, "TFS Valid Users", QueryMembership.Expanded);
        // Resolve to actual users
        Identity[] validUsers = gss.ReadIdentities(SearchFactor.Sid, validUserSids.Members, QueryMembership.None);
        List<string> Users = new List<string>();
        foreach (Identity user in validUsers)
        {
            Users.Add(user.DisplayName);
        }
        return Users.ToArray();
    }
private string[]TFSUsers(字符串服务器)
{
/获取对Team Foundation服务器的引用。
TeamFoundationServer tfs=tfsdata.GetTFS(服务器);
//获取对组安全服务的引用。
IGroupSecurityService gss=(IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService));
//决心解决小岛屿发展中国家问题
Identity validUserSids=gss.ReadIdentity(SearchFactor.AccountName,“TFS有效用户”,QueryMembership.Expanded);
//解析到实际用户
Identity[]validUsers=gss.readIdentifications(SearchFactor.Sid,validUserSids.Members,QueryMembership.None);
列表用户=新列表();
foreach(validUsers中的身份用户)
{
Users.Add(user.DisplayName);
}
返回Users.ToArray();
}

以下是如何获取TFS中的用户列表:

var tfs = TeamFoundationServerFactory.GetServer("http://vstspioneer:8080/tfs/VSTSDF");
var workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
var allowedValues = workItemStore.FieldDefinitions[CoreField.AssignedTo].AllowedValues;

foreach (String value in allowedValues)
{
    Console.WriteLine(value);
}

谢谢!那肯定更容易。还有什么办法像我一样将身份的概念与团体安全服务结合起来使用呢?我意识到我的帐户名称是错误的,应该是“Team Foundation有效用户”或“项目集合有效用户”,但它仍然不起作用。有什么建议吗?