I'm trying to add a field to a FeatureLayer, this is the code I'm using to do this:
IMxDocument mxd = (IMxDocument) app.getDocument();
FeatureLayer flayer = ((FeatureLayer)mxd.getSelectedLayer());
IField newField = null;
newField = new Field();
IFieldEdit newFieldEdit = (IFieldEdit) newField;
newFieldEdit.setAliasName("Id2");
newFieldEdit.setName("Id2");
newFieldEdit.setType(esriFieldType.esriFieldTypeString);
newFieldEdit.setLength(100);
flayer.addField(newFieldEdit);
However it raises an exception, according the documentation I should to get an ISchemaLock but I have no idea how to get a schemalock from a FeatureLayer, Does anyone have any idea?