The object has been updated by another user since it was last fetched.
In SharePoint I have created a Site Column and attach that site column using SharPoint Object model.
I have created a Separate method and I called it in Feature reaceiver’s FeatureActivated event.
My Method goes like this..
public void LinkFieldToContentType(SPWeb web, string contentType, SPField field)
SPContentType ct = web.ContentTypes[contentType];
catch (Exception ex)
Logger.WriteToLog(“Error Occurred while adding Content Type.”+ex.Message);
Here I am passing SPWeb from the FeaureActivated event’s SPFeatureReceiverProperties properties.
Passing the web creates an error “The object has been updated by another user since it was last fetched.” When the line ct.Update(true); get executed
I have modified the code something like this., which works. So it just want a new Instance of SPWeb
From FeatureActivated I call the below method like this..
Here Properties is SPFeatureReceiverProperties properties
using (SPWeb web = (SPWeb) properties.Feature.Parent)
if (siteColName != string.Empty)
SPFieldLink oFieldLink = new SPFieldLink(web.Fields.GetFieldByInternalName(siteColName));
SPContentType oContentType = web.ContentTypes[contentTypeName];
//Check the Field is not available already
if (oContentType != null && !oContentType.Fields.ContainsField(oFieldLink.DisplayName))