我正在开发一个基于ArcGIS Engine的独立应用程序,当我使用下面的代码块开始编辑会话时:
//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;
}
}
}
错误代码发生异常:HRESULT:0x80004005(E_FAIL))。请帮我
在询问Google并阅读ArcGIS Engine文档之后。我发现我的SDE GeoDatabase不允许编辑数据,因为我关闭了ArcGIS GeoDatabase的版本管理器。打开它并添加一些代码来检查要素图层是否可编辑。
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);
}