Sharepoint 2010 SPFieldUserValue:值不在预期范围内

Sharepoint 2010 SPFieldUserValue:值不在预期范围内,sharepoint-2010,Sharepoint 2010,下面的代码返回以下错误不确定问题出在哪里 异常详细信息:System.ArgumentException:值不在预期范围内 我的字符串类似于“S,Rishi”。为了创建SPFieldUserValue的实例,您应该传递以下格式的字符串: [国际]#[域]\[用户名] 从列表项中获取该值的最简单方法是: ListItem[field_GUID].ToString() 要创建SPFieldUserValue的实例,应传递以下格式的字符串: [国际]#[域]\[用户名] 从列表项中获取该值的最简单方法

下面的代码返回以下错误不确定问题出在哪里

异常详细信息:System.ArgumentException:值不在预期范围内


我的字符串类似于“S,Rishi”。

为了创建SPFieldUserValue的实例,您应该传递以下格式的字符串: [国际]#[域]\[用户名]

从列表项中获取该值的最简单方法是:
ListItem[field_GUID].ToString()

要创建SPFieldUserValue的实例,应传递以下格式的字符串: [国际]#[域]\[用户名]

从列表项中获取该值的最简单方法是: ListItem[field_GUID].ToString()

public static SPUser convertStringToSPUser(string struser)
{
    SPFieldUserValue userValue = new SPFieldUserValue(SPContext.Current.Web, struser);
    SPUser objSPUser = userValue.User;
    return objSPUser;
}