错误提示内容:
{System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at ESRI.ArcGIS.Display.AlgorithmicColorRampClass.CreateRamp(Boolean& ok) ...
写了一个简单的函数:
public IColorRamp CreateColorRamp(IColor fromColor, IColor toColor, int count) { IAlgorithmicColorRamp pRampColor; bool ok = true; pRampColor = new AlgorithmicColorRampClass(); pRampColor.FromColor = fromColor; pRampColor.ToColor = toColor; // ... missing size sentence pRampColor.CreateRamp(out ok); return pRampColor as IColorRamp; }
后来仔细检查代码,发现在以上黄色语句处少了pRampColor.Size = count;这句话,导致创建彩色条带的失败。但是仅仅给出“Error HRESULT E_FAIL has been returned from a call to a COM component.”这样的错误,我对ArcGIS的异常提示也是醉了,鬼知道这是什么错误。所以说在不考虑ArcGIS那几处优秀的设计地方外,可以说ArcGIS这个系统软件做的十分烂。
备注一下,省的以后再被ArcGIS这样的错误弄的一头雾水。