Guys, I am evaluating the Windows Phone SDK but cannot get a simple map to display. Application throws a NullReferenceException with details listed below:
System.NullReferenceException was unhandled
Message: An unhandled exception of type ‘System.NullReferenceException’ occurred in System.Windows.ni.dll
Additional information: Object reference not set to an instance of an object.
The XAML is simple enough:
<phone:PhoneApplicationPagex:Class=“PhoneApp2.Thgeo.MapView”xmlns="<a href=“schemas.microsoft.com/winfx/2006/xaml/presentation” tabindex=“0”>schemas.microsoft.com/winfx/...esentation</a>"xmlns:x="<a href=“schemas.microsoft.com/winfx/2006/xaml” tabindex=“0”>schemas.microsoft.com/winfx/2006/xaml</a>"xmlns:phone=“clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone”xmlns:shell=“clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone”xmlns:d="<a href=“schemas.microsoft.com/expression/blend/2008” tabindex=“0”>schemas.microsoft.com/expression/blend/2008</a>"xmlns:mc="<a href=“schemas.openxmlformats.org/markup-compatibility/2006” tabindex=“0”>schemas.openxmlformats.org/m...ility/2006</a>"xmlns:windowsPhoneEdition=“clr-namespace:ThinkGeo.MapSuite.WindowsPhoneEdition;assembly=WindowsPhoneEdition”mc:Ignorable=“d”FontFamily="{StaticResource PhoneFontFamilyNormal}"FontSize="{StaticResource PhoneFontSizeNormal}"Foreground="{StaticResource PhoneForegroundBrush}"SupportedOrientations=“Portrait”Orientation=“Portrait”shell:SystemTray.IsVisible=“True”><phone:PhoneApplicationPage.Resources><StyleTargetType=“ListBoxItem”><SetterProperty=“HorizontalContentAlignment”Value=“Stretch”/><!–</code–>Style><!–</code–>phone:PhoneApplicationPage.Resources>
<!–LayoutRoot is the root grid where all page content is placed–><Gridx:Name=“LayoutRoot”Background=“Transparent”><Grid.RowDefinitions><RowDefinitionHeight=“Auto”/><RowDefinitionHeight="*"/><!–</code–>Grid.RowDefinitions>
<!–TitlePanel contains the name of the application and page title–><StackPanelx:Name=“TitlePanel”Grid.Row=“0”Margin=“12,17,0,28”><TextBlockText=“MY APPLICATION”Style="{StaticResource PhoneTextNormalStyle}"Margin=“12,0”/><TextBlockText=“page name”Margin=“9,-7,0,0”Style="{StaticResource PhoneTextTitle1Style}"/><!–</code–>StackPanel>
<!–ContentPanel - place additional content here–><Gridx:Name=“ContentPanel”Grid.Row=“1”Margin=“12,0,12,0”><Grid.RowDefinitions><RowDefinitionHeight="*"/><RowDefinitionHeight=“Auto”/><!–</code–>Grid.RowDefinitions><windowsPhoneEdition:MapName=“Map”Width=“Auto”Height=“Auto”/><StackPanelGrid.Row=“1”Orientation=“Horizontal”><ButtonCommand="{Binding AddPointsCommand}"Width=“100”><ImageSource="…/Toolkit.Content/ApplicationBar.Add.png"><!–</code–>Image><!–</code–>Button><ButtonCommand="{Binding AddLineCommand}"Width=“100”><ImageSource="…/Toolkit.Content/ApplicationBar.Add.png"><!–</code–>Image><!–</code–>Button><ButtonCommand="{Binding AddPolygonCommand}"Width=“100”><ImageSource="…/Toolkit.Content/ApplicationBar.Add.png"><!–</code–>Image><!–</code–>Button><ButtonCommand="{Binding ShowLegendCommand}"Width=“100”><ImageSource="…/Toolkit.Content/ApplicationBar.Select.png"><!–</code–>Image><!–</code–>Button><!–</code–>StackPanel><!–</code–>Grid><!–</code–>Grid>
<!–</code–>phone:PhoneApplicationPage>
as well as the code behind:
public partial class MapView : IMapView
{
LayerOverlay _dynamicLayerOverlay = new LayerOverlay(“dlo”);
public MapView()
{
InitializeComponent();
Map.MapUnit = GeographyUnit.DecimalDegree;
Map.Overlays.Add(new WorldMapKitWmsWindowsPhoneOverlay());
Loaded += DisplayASimpleMap_Loaded;
}
void DisplayASimpleMap_Loaded(object sender, RoutedEventArgs e)
{
Map.CurrentExtent = new RectangleShape(-135.7, 83.6, 113.5, -53);
}
private void InitializeMapComponent()
{
// Map.ZoomLevel = 2;
}
}
But when I run this, the application just crashes, even though I copied this from one of the samples, which I also runs fine.
Do not know if this matters, but I am running this on a virtual machine.
Any ideas?