博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
对 COM 组件的调用返回了错误 HRESULT E_FAIL。ERROR 000622:
阅读量:5039 次
发布时间:2019-06-12

本文共 6526 字,大约阅读时间需要 21 分钟。

“对 COM 组件的调用返回了错误 HRESULT E_FAIL。ERROR 000622:”这个错误困扰了我一整天,网上找了好多解决方案,但统统都以失败告终。下面将网上找的纷纷列出来,并分析下失败的原因: 1.权限错误://初始化许可         IAoInitialize m_AoInitialize = new AoInitializeClass();      esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;         licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);      //3DAnalyst 扩展模块授权   m_AoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst); 我设置的权限为ARCINFO,不可能是此错误。(注:后来做AE开发的时候发现,虽然权限为ACRINfo,也会出现此错误 ,原因是在项目里面添加了ARCINFO 权限,又添加了liscense控件,可能是两个权限有冲突吧,去掉项目里AECINFO权限的上的勾或吧liscense控件删掉,呵呵,错误消失了),得改口了,有可能出现此错误。 2.以gp工具中的merge工具进行示例分析: (1)、当参数input所表示的要素类型不一致的时候会出现“对 COM 组件的调用返回了错误 HRESULT E_FAIL”提示。 (2)、当参数output所表示的要素已存在,且gp工具的overwrite属性设置为false的时候也会出现此提示,可以将overwrite 属性设置为true,这样就可以重写output而不会出现此问题。 (3)、input各要素之间没有用分号分隔。
View Code
1 private void CbxAddItems(ComboBox cbo, esriGeometryType geometryType)  2 {  3 IFeatureLayer featureLayer;  4 IEnumLayer layers = GetLayers();  5 if (layers == null) return;  6 layers.Reset();  7 ILayer layer = layers.Next();  8 while (layer != null)  9 { 10 if (layer is IFeatureLayer) 11 { 12 featureLayer = layer as IFeatureLayer; 13 if (featureLayer.FeatureClass.ShapeType == geometryType) 14 { 15 cbo.Items.Add(layer.Name); 16 } 17 } 18 layer = layers.Next(); 19 } 20 } 21  22 private void CbxAddItems(ComboBox cbo, esriGeometryType geometryType, IFeatureLayer inputLayer) 23 { 24 esriGeometryType inputGeometryType = inputLayer.FeatureClass.ShapeType; 25 string inputName = inputLayer.Name; 26 IFeatureLayer featureLayer; 27 IEnumLayer layers = GetLayers(); 28 if (layers == null) return; 29 layers.Reset(); 30 ILayer layer = layers.Next(); 31 while (layer != null) 32 { 33 if (layer is IFeatureLayer) 34 { 35 featureLayer = layer as IFeatureLayer; 36 if (featureLayer.Name == inputName) goto label1; 37 if (featureLayer.FeatureClass.ShapeType == geometryType) 38 { 39 cbo.Items.Add(layer.Name); 40 } 41 } 42 label1: layer = layers.Next(); 43 } 44 } 45  46 private void CbxAddItems(ComboBox cbo, IFeatureLayer inputLayer) 47 { 48 esriGeometryType inputGeometryType = inputLayer.FeatureClass.ShapeType; 49 string inputName = inputLayer.Name; 50 IFeatureLayer featureLayer; 51 IEnumLayer layers = GetLayers(); 52 if (layers == null) return; 53 layers.Reset(); 54 ILayer layer = layers.Next(); 55 while (layer != null) 56 { 57 if (layer is IFeatureLayer) 58 { 59 featureLayer = layer as IFeatureLayer; 60 if (featureLayer.Name == inputName) goto label1; 61 cbo.Items.Add(layer.Name); 62 } 63 label1: layer = layers.Next(); 64 } 65 } 66  67 private void CbxAddItemsForErase(ComboBox cbo, IFeatureLayer inputLayer) 68 { 69 esriGeometryType inputGeometryType = inputLayer.FeatureClass.ShapeType; 70 string inputName = inputLayer.Name; 71 IFeatureLayer featureLayer; 72 IEnumLayer layers = GetLayers(); 73 if (layers == null) return; 74 layers.Reset(); 75 ILayer layer = layers.Next(); 76 while (layer != null) 77 { 78 if (layer is IFeatureLayer) 79 { 80 featureLayer = layer as IFeatureLayer; 81 if (featureLayer.Name == inputName) goto label1; 82 esriGeometryType overlayGeometryType = featureLayer.FeatureClass.ShapeType; 83  84 if (inputGeometryType == esriGeometryType.esriGeometryPoint ) 85 { 86 if (overlayGeometryType == esriGeometryType.esriGeometryPoint || overlayGeometryType == esriGeometryType.esriGeometryMultipoint) 87 { 88 cbo.Items.Add(layer.Name); 89 } 90 } 91 else if (inputGeometryType == esriGeometryType.esriGeometryPolyline) 92 { 93 if (overlayGeometryType == esriGeometryType.esriGeometryPolyline || overlayGeometryType == esriGeometryType.esriGeometryPolygon) 94 { 95 cbo.Items.Add(layer.Name); 96 } 97 } 98 else if (inputGeometryType == esriGeometryType.esriGeometryPolygon) 99 {100 if (overlayGeometryType == esriGeometryType.esriGeometryPolygon)101 {102 cbo.Items.Add(layer.Name);103 }104 }105 else106 {107 return;108 }109 110 }111 label1: layer = layers.Next();112 }113 }114 115 private void CbxAddItemsForIdentity(ComboBox cbo, IFeatureLayer inputLayer)116 {117 esriGeometryType inputGeometryType = inputLayer.FeatureClass.ShapeType;118 string inputName = inputLayer.Name;119 IFeatureLayer featureLayer;120 IEnumLayer layers = GetLayers();121 if (layers == null) return;122 layers.Reset();123 ILayer layer = layers.Next();124 while (layer != null)125 {126 if (layer is IFeatureLayer)127 {128 featureLayer = layer as IFeatureLayer;129 if (featureLayer.Name == inputName) goto label1;130 esriGeometryType overlayGeometryType = featureLayer.FeatureClass.ShapeType;131 if (overlayGeometryType == inputGeometryType || overlayGeometryType == esriGeometryType.esriGeometryPolygon)132 {133 cbo.Items.Add(layer.Name);134 }135 }136 label1: layer = layers.Next();137 }138 }139 140 private void CbxAddItemsForSymDiff(ComboBox cbo, IFeatureLayer inputLayer)141 {142 esriGeometryType inputGeometryType = inputLayer.FeatureClass.ShapeType;143 string inputName = inputLayer.Name;144 IFeatureLayer featureLayer;145 IEnumLayer layers = GetLayers();146 if (layers == null) return;147 layers.Reset();148 ILayer layer = layers.Next();149 while (layer != null)150 {151 if (layer is IFeatureLayer)152 {153 featureLayer = layer as IFeatureLayer;154 if (featureLayer.Name == inputName) goto label1;155 esriGeometryType overlayGeometryType = featureLayer.FeatureClass.ShapeType;156 if (overlayGeometryType == inputGeometryType)157 {158 cbo.Items.Add(layer.Name);159 }160 }161 label1: layer = layers.Next();162 }163 }

 

以上代码严格控制了输入要素和叠加要素的类型,所以也不会可能是此错误 找了好久终于找到了错误的根源。原来是
IGpValueTableObject vtobject = new GpValueTableObjectClass();            vtobject.SetColumns(1);            object row = "";            //加入输入图层            row = GetFeatureLayer(strInputLayer);            vtobject.AddRow( ref row);            //加入输出图层            row = GetFeatureLayer(strOverLayLayer);            vtobject.AddRow(ref row);            IVariantArray pVarArry = new VarArrayClass();            pVarArry.Add(vtobject);            string outputFullPath = System.IO.Path.Combine(strOutputPath, strInputLayer + "_" + strOverLayLayer + "_" + "Intersect");            pVarArry.Add(outputFullPath);                      pVarArry.Add(strOutputAttributeType);            pVarArry.Add(tolerance);            pVarArry.Add(strOutputFeatureType);            IGeoProcessorResult results = gp.Execute("Union_analysis", pVarArray, null) as IGeoProcessorResult;

pVarVarry的添加参数的参数顺序在此捣乱,一定要按照规定顺序才有用。

转载于:https://www.cnblogs.com/tlywelcome/archive/2012/06/27/2565807.html

你可能感兴趣的文章
【BZOJ】3142: [Hnoi2013]数列
查看>>
http初探
查看>>
elasticsearch的安装
查看>>
__next__()
查看>>
爬取:中国大学排名
查看>>
聊天室(C++客户端+Pyhton服务器)_1.框架搭设
查看>>
UpdatePanel 内控件 更新“外的”控件【转】
查看>>
mybatis中>=和<=的实现方式
查看>>
Python面向对象03/继承
查看>>
java序列化和反序列化
查看>>
绝对定位
查看>>
flink源码编译(windows环境)
查看>>
dpkg 删除 百度网盘 程序
查看>>
服务器nginx安装
查看>>
std::nothrow
查看>>
rest-framework 分页器
查看>>
JQuery(一)安装&选择器 样式篇
查看>>
浏览器的DNS缓存查看和清除
查看>>
浏览器跨域问题
查看>>
HTML5 input控件 placeholder属性
查看>>