我正在尝试将Adusers列表添加到词典中但由于某种原因,它适用于1名用户,其名称为“a”,但对于第二个用户“abcdedf ancdef”,它给我这个例外,
_COMPlusExceptionCode = 0xe0434f4d
if (member != null && !string.IsNullOrEmpty(member.UserName))
{
string MemberName = member.UserName.ToString().Replace(".", " ");
UserList.Add(groupName, MemberName);
}
这是我在调试时得到的,没有线索去哪里找到解决方案,这里是代码
protected override void CreateChildControls()
{
base.CreateChildControls();
try
{
TreeView tree = new TreeView();
TreeNode groupNode = default(TreeNode);
List<string> GroupList = new List<string>();
Dictionary<string, string> UserList = new Dictionary<string, string>();
List<string> IndividualUserList = new List<string>();
foreach (SPUser user in SPContext.Current.Web.Users)
{
string groupName = FormatUserLogin(user.Name);
if (!user.IsDomainGroup && groupName != "" && groupName != "System Account")
IndividualUserList.Add(groupName);
else if (user.IsDomainGroup && !string.IsNullOrEmpty(groupName) &&
Directory.DoesGroupExist(groupName))
{
GroupList.Add(groupName);
foreach (ADUser member in Directory.GetUsersFromGroup(groupName))
{
if (member != null && !string.IsNullOrEmpty(member.UserName))
{
string MemberName = member.UserName.ToString().Replace(".", " ");
UserList.Add(groupName, MemberName);
}
}
}
}
IndividualUserList.Sort();
foreach (string Item in IndividualUserList)
{
groupNode = new TreeNode(Item);
}
foreach (string GroupListItem in GroupList)
{
groupNode = new TreeNode(GroupListItem);
foreach (KeyValuePair<string, string> UserPair in UserList)
{
if (UserPair.Key == GroupListItem)
{
groupNode.ChildNodes.Add(new TreeNode(UserPair.Value));
}
}
}
if (groupNode != null)
{
tree.Nodes.Add(groupNode);
this.Controls.Add(tree);
}
tree.Nodes.Add(groupNode);
}
catch (Exception)
{
//loggingit
}
}