am building a webservice with ArcObjects in C# .Net to insert a new feature or update an existing feature to a SDE-table. I am using the IFeatureCursor and an IFeatureBuffer to insert the features. When the geometry field ("Shape") is set, an COMException is thrown saying:

"Unable to update area or length field in response to shape update"

Obviously this refers to the default feature class fields Shape.area and Shape.length that are calculated automatically. I have also tried to insert features using the CreateFeature() and feature.Store() method, but this resulted in the same exception.

Just to be clear, this happens before I call the cursor.InsertFeature(featureBuffer) or cursor.UpdateFeature(feature) method.

My code looks like this:

private void Create(Result result)
        var featureClassLoad = (IFeatureClassLoad) _master;
        var schemaLock = (ISchemaLock) _master;
        IFeatureCursor cursor = null;
        IFeatureBuffer featureBuffer = null;

            featureClassLoad.LoadOnlyMode = true;
            cursor = _master.Insert(false);
            featureBuffer = _master.CreateFeatureBuffer();

            foreach (var attr in result.Attributes)
                var attributeName = attr.Field.Name;
                var index = _master.FindField(attributeName);
                if (attributeName == _master.ShapeFieldName)
                    featureBuffer.Value[index] = attr.NewGeometry;//Exception thrown

                if (attributeName == "ID")
                    featureBuffer.Value[index] = "{" + result.Guid.ToString().ToUpper() + "}";
                featureBuffer.Value[index] = attr.NewValue;
            if (featureBuffer != null) Marshal.ReleaseComObject(featureBuffer);
            if (cursor != null) Marshal.ReleaseComObject(cursor);
            featureClassLoad.LoadOnlyMode = false;

Any suggestions are more than welcome!

  • Are you trying to update a column, or the read-only property of the geometry? – Vince Mar 24 '14 at 15:33
  • The exception occurs whenever I set the shapefield of the IFeatureBuffer. So if I understand you question correctly, I am trying to update a the geometry column. – BenSav Mar 24 '14 at 15:53
  • You can update the geometry coordinates, but not the area or length properties. Once the coordinates are changed, the area and length values are changed accordingly. – Vince Mar 24 '14 at 16:15
  • Well, that is the problem. I update the geometry coordinates. At the moment this is executed in code arcobjects uses these coordinates to fill the Shape.area and Shape.Length automatically. That is when something goes wrong. I don't update these area and length fields myself... – BenSav Mar 24 '14 at 16:25
  • It looks like your logic could be trying to update the area/length pseudo-columns. What is the complete column list generated by result.Attributes? – Vince Mar 24 '14 at 17:51

I solved my problem. The entire flow of my code was executed within one servercontext. I suppose therefore some references to the table were not released sufficiently however I always released the FeatureCursors and Workspaces when not longer needed.

I solved my problem by creating and releasing different servercontexts for different parts of my code. Existing references are released more thoroughly now.

Thx to all who have helped!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.