Enable Rating Settings on SharePoint list programmatically

15/03/2016 16:21

public static void EnableRatingOnList(SPList list)
{
 Assembly assembly = Assembly.Load("Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
 Type reputationHelper = assembly.GetType("Microsoft.SharePoint.Portal.ReputationHelper");

 //MethodInfo method1 = reputationHelper.GetMethod("DisableReputation", BindingFlags.Static ' BindingFlags.NonPublic);
 //method1.Invoke(null, new Object[] { list });

 MethodInfo method2 = reputationHelper.GetMethod("EnableReputation", BindingFlags.Static ' BindingFlags.NonPublic);
 // "Likes" or "Ratings" as per your requirement.
 method2.Invoke(null, new Object[] { list, "Likes", false });

 list.Update();
}