I received this error while working on some ArcObjects Code.
Objects in this class cannot be updated outside an edit session.
It had to do with the relationships that I established inside the File Geodatabase I was saving to.
So I had to add a few lines and open up an EDIT SESSION on the workspace. I guess if you don’t have any relationships, you don’t need an edit session, but when you start using relationships you have to start opening up an edit session.
So here is my code. You will notice the 3 lines that open the IWorkspaceEdit and the last two lines that stop editing.
//First thing is to create a generic fGDB workspace factory class
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();
//Create a workspace and point it to the fGDB file
IWorkspace workspace = workspaceFactory.OpenFromFile(DATABASE_PATH_WITH_ATTACHMENTS, 0) as IWorkspace;
IWorkspaceEdit edit = (IWorkspaceEdit)workspace;
//Add some EDIT code here to the DB...
//Remove references to the fGDB
workspaceFactory = null;
workspace = null;
datasets = null;