I have been using the method described here by attempting to use reflection to turn on the Rating Settings of a list. However, I get the following error:
Exception Message: exception has been thrown by the target of an invocation
Stacktrace Message: Value cannot be null.Parameter name: serviceContext
Here is my attempt:
//Create the list Guid id = web.Lists.Add("Board Name", "Board Desc", SPListTemplateType.DiscussionBoard); web.Update(); //Retrieve the list I just created SPList discBoardList = web.Lists[id]; //Attempt to turn on the Rating Settings for the newly created list Type type = typeof(Microsoft.SharePoint.Portal.RatingsSettingsPage); MethodInfo mi = type.GetMethod("EnableRatings", BindingFlags.Static | BindingFlags.NonPublic); mi.Invoke(null, new object[] { discBoardList, true }); //EXCEPTION THROWN How do I resolve this issue? Or more importantly is there an easier/better way to turn on Rating Settings for a SharePoint list programmatically?