0

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.

stefanobaghino
  • 11,253
  • 4
  • 35
  • 63

1 Answers1

0

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

Gwen Royakkers
  • 431
  • 2
  • 11
  • i have checked the ArcGIS Administrator , the licence level is Standard. BTW: I develop an application that connects to ArcGIS , not an extension to ArcMap. Shlomy – user3748781 Feb 21 '18 at 12:33
  • I need some clarity on the topic. Are you building a stand alone application that uses ArcObjects (ArcMap or Arcgis Engine installed) or are you targetting Arcgis Server? If it is the first case, I've added the details to my previous answer. – Gwen Royakkers Feb 21 '18 at 12:51