Index was out of range. Must be non-negative and less than the size of the collection
在执行函数Init的第一句base.Init(el);时,出现如题的错误。
public override void Init(System.Xml.Linq.XElement el) { base.Init(el); //解析类型 GetMapType(el); //解析MapList GetMapList(el); //GetBusTaskInfo(el); GetTaskInfo(el); GetUpdateIDsInfo(el); m_workshop = this; if (this.Initialized != null) { this.Initialized(this, new EventArgs()); } }
错误原因可能是基类出现了错误或者是配置文件有误。很显然是后者,应该是出现在配置文件App.xml中。经过排查,发现了问题出在:
<!--英德市 采矿许可证 地块 查询-->
<Task ID="ydCKXKZ" SourceType="NewMap" ServiceType="QueryTask">
<Url>http://192.168.1.123:8719/NewMapServer/WebServices/FeatureServer.php?layer=ydCKXKZ</Url>
<QueryFileds>KSMC,CKQR</QueryFileds>
<Epsg>4610</Epsg>
</Task>
将其改为下面的配置:
<!--英德市 采矿许可证 地块 查询-->
<Task ID="ydCKXKZ" SourceType="NewMap" ServiceType="QueryTask">
<Url>http://192.168.1.123:8719/NewMapServer/WebServices/FeatureServer.php?layer=ydCKXKZ</Url>
<PageSize>10</PageSize>
<Filed>KSMC,CKQR</Filed>
</Task>
同时,还有几处比较隐蔽的错误,需要自己逐个地排查:
比如ServiceType=“WMTS" 改为ServiceType="WMTSLayer";
在检查的过程中,还发现了更加低级的错误:"Field"写为了”Filed“,所以,在检查配置文件过程中,一定要细心。

浙公网安备 33010602011771号