I have layer (feature class) in ArcGIS. The data is on Oracle 11g.
I try to update a field in a row but when I do feature.store
I get an error
Class is not licensed for use (Exception from HRESULT: 0x80040112)
Attached code :
private void UpdateFeatures(IFeatureClass featureClass, IFeatureWorkspace featureWorkspace, List<FeatureValue> featureValues)
{
IFeatureCursor featureSearchCursor = null;
IWorkspaceEdit workspaceEdit = null;
try
{
workspaceEdit = (IWorkspaceEdit)featureWorkspace;
workspaceEdit.StartEditing(false);
// Start an edit operation and create a cursor.
workspaceEdit.StartEditOperation();
//IQueryFilter queryFilter = new QueryFilter();
//queryFilter.WhereClause = "Code = '" + featureValues[i].FieldName + "'";
//queryFilter.SubFields = "COMMENTS";
featureSearchCursor = featureClass.Search(null, false);
int fieldCodeIndex = featureClass.FindField("CODE");
int fieldIndex = featureClass.FindField("MODEL");
bool FieldEditable = featureWorkspace.OpenTable("Switch").Fields.get_Field(fieldIndex).Editable;
// Iterate through the features, updating the Type values.
IFeature feature = null;
while ((feature = featureSearchCursor.NextFeature()) != null)
{
object obj = feature.get_Value(fieldCodeIndex);
if (!(obj is DBNull))
{
FeatureValue featureValue = featureValues.Where(x => x.FieldName == obj.ToString()).FirstOrDefault<FeatureValue>();
if (featureValue != null)
{
int val = featureValue.FieldValue;
}
object obj1 = "123";
feature.set_Value(fieldIndex,obj1);
feature.Store();
break;
}
//Console.WriteLine("The new type: {0}", feature.get_Value(fieldIndex));
}
}
catch (COMException ex)
{
// Handle any errors that might occur on NextFeature().
richTextBox1.AppendText(ex.Message);
}
catch (Exception ex)
{
//handle general Errors
richTextBox1.AppendText(ex.Message);
}
finally
{
workspaceEdit.StopEditOperation();
// Stop the edit session.
workspaceEdit.StopEditing(true);
// Stop the edit operation.
// Since the edit operation is ending, release the cursor.
Marshal.ReleaseComObject(featureSearchCursor);
}
}
Many thanks for any advice.
Check that the correct ArcGis license level is used. For an AddIn/Extension The licence level that is used will be the one set in "ArcGIS Administrator" When you have multiple licenses, 'Desktop Basic' is often set, and the license level isn't high enough to edit SDE databases.
This kind of error is described here: ESRI Error: Not Licensed
If you need an extension, make sure it is enabled and licensed.
For a StandAlone Application that uses ArcObjects you need to initialize the license yourself. For this I recommend the ESRI Documentation AoInitialize CoClass And the Initialize Method
The samples should be Able to help
User contributions licensed under CC BY-SA 3.0