Arcgis Engine The supplied command does not exist in command pool?

private IGeometry GetMergeGeometry()
{
IFeatureLayer pFeatureLayer = mainMapControl1.get_Layer(1) as IFeatureLayer;
IGeometryBag pGeometryBag = new GeometryBag() as IGeometryBag;
pGeometryBag.SpatialReference = GetSpatialReference();
IGeometryCollection pGeometryCollection = pGeometryBag as IGeometryCollection;

// 属性过滤
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.AddField("Shape");

// 要素游标
IFeatureCursor pFeatureCursor = pFeatureLayer.FeatureClass.Search(pQueryFilter, true);
IFeature pFeature = pFeatureCursor.NextFeature();
if (pFeature == null)
{
return null;
}

// 遍历游标
object missing = Type.Missing;
while (pFeature != null)
{
pGeometryCollection.AddGeometry(pFeature.ShapeCopy, ref missing, ref missing);
pFeature = pFeatureCursor.NextFeature();
}
Marshal.ReleaseComObject(pFeatureCursor);

// 合并要素
ITopologicalOperator2 pTopologicalOperator = null;
if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
{
pTopologicalOperator = new Multipoint() as ITopologicalOperator2;
pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);
}
else if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
pTopologicalOperator = new Polyline() as ITopologicalOperator2;
pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);
}
else
{
pTopologicalOperator = new Polygon() as ITopologicalOperator2;
//问题显示:使用的工具并未在工具池中找到。
pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);
}
return pTopologicalOperator as IGeometry;
}
1、为了解决 TopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry);“未指定的错误(Exception from hresult:0x80004005(E_FAIL))”的问题,用管理员身份打开VS,问题变为The supplied command does not exist in command pool。
 
已邀请:

blue - Less is more.

赞同来自: wang2543311

我做Engine开发也遇到了这个错误,请问楼主解决了吗?
 
--------------------------------------------------------------
已解决,最后竟然是许可的问题...

朱新颖

赞同来自:

pFeatureLayer.FeatureClass.Search(pQueryFilter, true);第二个参数改为false试试

要回复问题请先登录注册