Video of the week

This is a must-watch video about one of us trying to reach the stars :-)

Well done #HRejterzy

Failed to create a 'System.Device.Location.GeoCoordinate' from the text

Failed to create a 'System.Device.Location.GeoCoordinate' from the text (problem - solution)

When You test code included in book Windows Phone 7 (..) by Henry Lee, Eugene Chuvyrov You can reach the moment when You get above error. Problem is related to the situation when Pushpin's Content depends on the object that has not been created yet.

geo error


  1. <BingMap:Map x:Name="bingMap" ZoomLevel="4" ZoomBarVisibility="Visible"
  2. CopyrightVisibility="Collapsed" LogoVisibility="Collapsed" Grid.Row="2">
  4. <BingMap:Pushpin Name="bingMapLocator">
  5. <!--
  6. <BingMap:Pushpin.Content>
  7. <Ellipse Fill="Red" Width="20" Height="20" BingMap:MapLayer.Position="0,0" Name="Locator"/>
  8. </BingMap:Pushpin.Content>
  9. -->
  10. </BingMap:Pushpin>
  12. </BingMap:Map>


I commented out the part of code which I decided to move to the code behind file, check this:

geo error solution


  1. Location location = new Location();
  2. location.Latitude = latitude;
  3. location.Longitude = longitude;
  5. bingMap.SetView(location, zoomLevel);
  6. MapLayer.SetPosition(this.bingMapLocator, location);


Above code is related to setting position of Pushpin - in XAML and by default it was set in 0,0 (latitude & longitude) position and that is the moment when application crashes. MapLayer.SetPosition == BingMap:MapLayer.Position - so if You decide to move BingMap:MapLayer.Position code from XAML and set it in code behind using MapLayer.Position - it will work. I decided to do a little more than that in code behind (additionally I created Pushpin's Content in code behind - You don't have to) - You can decide to choose one of those two solutions.

Now it works. After InitializeComponent() method I am sure that when I decide to set Pushpin's Content - that object exists and I won't get this error again.