ArcGIS API for Silverlight 入门学习笔记(一)hello world 补充问题

相关代码,点击这里

今天莫名其妙出现了这个错误

是否要调用此页面?

此页面包含一些错误,这些错误可能会阻止页面正确显示或运行。如果不想现在测试页面,则单击“否”。

错误:缺少对象

经过多次查看代码,看不出哪里出问题了,然后在上面的图层中加入InitializationFailed属性

前台代码
<UserControl x:Class="APIforSilverlightSamp.s2"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d
="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ESRI
="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
mc:Ignorable
="d">
<Grid x:Name="LayoutRoot" Background="White">
<ESRI:Map x:Name="mymap">
<ESRI:Map.Layers>
<ESRI:ArcGISTiledMapServiceLayer ID="layerworldmap" InitializationFailed="ArcGISTiledMapServiceLayer_InitializationFailed"
Url
="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer" />
</ESRI:Map.Layers>
</ESRI:Map>
</Grid>
</UserControl>
后台代码
private void ArcGISTiledMapServiceLayer_InitializationFailed(object sender, EventArgs e)
{
ESRI.ArcGIS.Client.Layer layer
= sender as ESRI.ArcGIS.Client.Layer;
MessageBox.Show(layer.InitializationFailure.ToString());
}

然后会看到如下提示

看到此提示,恍然大悟,我调用的是ESRI提供的服务,但是我现在的网络访问受限(在公司,上午10点之前只能打开百度,MSDN等网站,谷歌也不开,不知道拍脑袋的领导是怎么想的,不罗嗦了,你懂的)。10点过后,完全可以正常访问。

原文地址:https://www.cnblogs.com/junyuz/p/1933578.html