Subscribing to RowCreatedEvent results in "Failed to create feature"

232
0
01-31-2024 12:48 AM
CarstenAndersson
Occasional Contributor

Hi.

I'm trying to create a row in a table whenever a feature in another feature class has been created. Inside my code I'm subscribing to the RowCreatedEvent like so:

RowCreatedEvent.Subscribe(OnRowCreated, table); // The table is the feature class mentioned

I have a method called OnRowCreated and whenever a feature is created in the feature class, the code is actually going to that method. So that part is working.

In the OnRowCreated method I have the following lines:

using var geoDatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(...)));
using var table = geoDatabase.OpenDataset<Table>(...);
var attribs = new Dictionary<string, object?> { { "LCID", "Testing" } };
args.Operation.Create(table, attribs);

When I run the code it's stepping through and the geoDatabase and the table variables are filled with the correct values. The table is where I want to create a new row. I also made sure the feature class and table is editable. I then create a dictionary with one attribute and value, since none of the fields are mandatory, meaning they are all nullable. My code passes through without errors or exceptions. After that ArcGIS Pro shows me this:

CarstenAndersson_0-1706690594730.png

The feature is not created and no new row is created in the table. I turned on the Diagnostics Monitor, and this is what I see

CarstenAndersson_2-1706690709033.png

I'm stuck so any help is greatly appreciated 🙂

Regards

Carsten

Tags (3)
0 Kudos
0 Replies