huangs3

Error caused byIEditor.AbortOperation called at IEditorEvents.OnCreateFeature handler

Discussion created by huangs3 on Nov 5, 2013
Hi Everybody:

    I wrote some C# code like this:

IEditor m_editor = ...
IFeatureClass featCls = ...

(m_editor as IEditorEvents_Events).OnCreateFeature = ... // the handler calls m_editor.AbortOperation in some situation
m_editor.StartOperation();
IFeature feat = featCls.CreateFeature();
// modify feat
feat.Store();
m_editor.StopOperation("Create Feature");



When the code is execute, the IEditorEvents.OnCreateFeature event handler is triggered when feat.Store() is run. In the event handler if m_editor.AbortOperation is call in some situation to abort the feature creation. However, I got exception:
**************************************
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at ESRI.ArcGIS.Geodatabase.IFeature.Store()
**************************************

Why does this happen? How can I let the event handler abort the operation?

Thank you!

Outcomes