MapResource对象转换问题
我的 MapResourceManager 中有一个名为“MapResourceItem0”的“ArcGIS Server Internet”资源,它是其他两个资源中的第三个。
我需要获取此资源中图层的功能,但无法获取 MapResource 对象
此方法
IMapResource mapresource = mapresourcemanager1.GetResource(2);
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphics_mapresource =
(ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)mapresource;
和此方法
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphicsresource = null;
foreach (IGISFunctionality gisfunctionality in map1.GetFunctionalities())
{
if (gisfunctionality.Resource.Name == "MapResourceItem0")
{
graphicsresource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)
gisfunctionality.Resource;
}
}
都失败,并出现以下错误
System.InvalidCastException: Cannot cast an object from 'ESRI.ArcGIS. ADF.Web.DataSources.ArcGISServer.MapResourceInternet' 到 'ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource'。
我不明白,示例和文档清楚地表明这是可以接受的,这有什么问题吗?我正在使用 arcgis 服务器 10
I have an 'ArcGIS Server Internet' resource into my MapResourceManager called "MapResourceItem0" and is the third of other two resources.
I need to get the features of the layers in this resource, but I can't obtain the MapResource object
Either this method
IMapResource mapresource = mapresourcemanager1.GetResource(2);
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphics_mapresource =
(ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)mapresource;
and this
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphicsresource = null;
foreach (IGISFunctionality gisfunctionality in map1.GetFunctionalities())
{
if (gisfunctionality.Resource.Name == "MapResourceItem0")
{
graphicsresource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)
gisfunctionality.Resource;
}
}
are failing with the following error
System.InvalidCastException: Cannot cast an object from 'ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceInternet' to 'ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource'.
I don't understand, examples and documentation clearly states this is acceptable, what's wrong with that? I'm using arcgis server 10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我(幸运的是)没有安装 Web ADF。无法将 ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceInternet 转换为需要服务器上下文的任何内容。
但 ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceInternet 实现 IMapResource 所以也许你可以这样做:
I (luckily) do not have the web ADF installed. It is not possible to cast a ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceInternet to anything that needs the server context.
But ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceInternet implements IMapResource so maybe you can do: