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:PhoneApplicationPage
x: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
>
<
Style
TargetType
=
“ListBoxItem”
>
<
Setter
Property
=
“HorizontalContentAlignment”
Value
=
“Stretch”
/>
<!–</code–>
Style
>
<!–</code–>
phone:PhoneApplicationPage.Resources
>
<!–LayoutRoot is the root grid where all page content is placed–>
<
Grid
x:Name
=
“LayoutRoot”
Background
=
“Transparent”
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
“Auto”
/>
<
RowDefinition
Height
=
"*"
/>
<!–</code–>
Grid.RowDefinitions
>
<!–TitlePanel contains the name of the application and page title–>
<
StackPanel
x:Name
=
“TitlePanel”
Grid.Row
=
“0”
Margin
=
“12,17,0,28”
>
<
TextBlock
Text
=
“MY APPLICATION”
Style
=
"{StaticResource PhoneTextNormalStyle}"
Margin
=
“12,0”
/>
<
TextBlock
Text
=
“page name”
Margin
=
“9,-7,0,0”
Style
=
"{StaticResource PhoneTextTitle1Style}"
/>
<!–</code–>
StackPanel
>
<!–ContentPanel - place additional content here–>
<
Grid
x:Name
=
“ContentPanel”
Grid.Row
=
“1”
Margin
=
“12,0,12,0”
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"*"
/>
<
RowDefinition
Height
=
“Auto”
/>
<!–</code–>
Grid.RowDefinitions
>
<
windowsPhoneEdition:Map
Name
=
“Map”
Width
=
“Auto”
Height
=
“Auto”
/>
<
StackPanel
Grid.Row
=
“1”
Orientation
=
“Horizontal”
>
<
Button
Command
=
"{Binding AddPointsCommand}"
Width
=
“100”
>
<
Image
Source
=
"…/Toolkit.Content/ApplicationBar.Add.png"
><!–</code–>
Image
>
<!–</code–>
Button
>
<
Button
Command
=
"{Binding AddLineCommand}"
Width
=
“100”
>
<
Image
Source
=
"…/Toolkit.Content/ApplicationBar.Add.png"
><!–</code–>
Image
>
<!–</code–>
Button
>
<
Button
Command
=
"{Binding AddPolygonCommand}"
Width
=
“100”
>
<
Image
Source
=
"…/Toolkit.Content/ApplicationBar.Add.png"
><!–</code–>
Image
>
<!–</code–>
Button
>
<
Button
Command
=
"{Binding ShowLegendCommand}"
Width
=
“100”
>
<
Image
Source
=
"…/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?