The parameter is (or has an element that is) the wrong kind of geometry
今天開發遇到一個問題,就是將一個 IPolygon 對象添加到另外一個 IPolygon 中,代碼示例如下:
IPolygon polygon1 = new PolygonClass();
IPolygon polygon2 = new PolygonClass();
IGeometryCollection collection = polygon1 as IGeometryCollection;
object obj = Type.Missing;
collection.AddGeometry(polygon2 as IGeometry, ref obj, ref obj);
結果執行 collection.AddGeometry(polygon2 as IGeometry, ref obj, ref obj); 這個語句時出現如上異常信息,提示的意思是幾何對象的類型錯誤,心想 IGeometryCollection 不是可以添加 IGeometry 對象嗎,而 IPolygon 轉換為 IGeometry 也沒錯的啊。經過多次嘗試后才知道并不是用 AddGeometry 方法,而該使用 AddGeometryCollection 方法。調整為如下代碼,測試通過。
IGeometryCollection collection = polygon1 as IGeometryCollection;
collection.AddGeometryCollection(polygon2 as IGeometryCollection);
轉載鏈接:http://www.xuebuyuan.com/1351788.html
總結
以上是生活随笔為你收集整理的The parameter is (or has an element that is) the wrong kind of geometry的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 京瓷4501i打印机扫描步骤_京瓷网络扫
- 下一篇: java print快捷键_JAVA中最