Cannot edit a feature layer when I start a session editing

-1

I am developing a standalone app based on ArcGIS Engine, and when I starting a session editing with the code block below:

//Declare the Engine editor at the class level.
private IEngineEditor m_engineEditor = new EngineEditorClass();

private void StartEditing(IMapControl2 m_mapControl)
{
    IMap map = m_mapControl.Map;

    //If an edit session has already been started, exit.
    if (m_engineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
        return ;

    //Start editing the workspace of the first feature layer found.
    for (int layerCounter = 0; layerCounter <= map.LayerCount - 1; layerCounter++)
    {
        ILayer currentLayer = map.get_Layer(layerCounter);
        if (currentLayer is IFeatureLayer)
        {
            IFeatureLayer featureLayer = currentLayer as IFeatureLayer;
            IDataset dataset = featureLayer.FeatureClass as IDataset;
            IWorkspace workspace = dataset.Workspace;
            m_engineEditor.StartEditing(workspace, map);
            ((IEngineEditLayers)m_engineEditor).SetTargetLayer(featureLayer);
            break;
        }
    }
}

An exception occurred with error code: HRESULT: 0x80004005 (E_FAIL)). Please help me

gis
arcgis
arcobjects
asked on Stack Overflow Mar 26, 2019 by Hoàng Hiệp Nguyễn • edited Mar 26, 2019 by Ulysse BN

1 Answer

0

After asking Google and reading ArcGIS Engine documents. I found my SDE GeoDatabase does not allow editing data, because I turn off version manager of ArcGIS GeoDatabase. Turn on it and add some code to check feature layer is editable.

IEngineEditLayers m_engineLayersEditor = m_engineEditor as IEngineEditLayers;
if (!m_engineLayersEditor.IsEditable(featureLayer))
{
    MessageBox.Show("Can not start editing. Because feature layer is not allow editing", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

User contributions licensed under CC BY-SA 3.0