title: silverlight navigationservice
body: <p>Working on a windows 7 phone app.  I am having a problem where the navigationservice keeps coming up that it's a null referrence exception.</p>
  
  <p>Here is where it's loading up the navigate</p>
  
  <pre><code>Dim x As PrivDempsey.PagesList = CType(Me.lbTaskList.SelectedItem, PrivDempsey.PagesList)
      NavigationService.Navigate(New Uri(x.itsURI, UriKind.Relative))
  </code></pre>
  
  <p>x looks like this   </p>
  
  <pre><code>.Name1 = "Sucss"  
  .itsURI = "/Pages/WSError/List.xaml?SiteID=1&amp;Access=Cossacks"
  </code></pre>
  
  <p>in the list page, it looks like this  </p>
  
  <pre><code>NavigationContext.QueryString.TryGetValue("Access", pSiteID).  
  </code></pre>
  
  <p>I have that in the public sub new after the <code>InitializeComponent</code>.</p>
  
  <p>The thing is.. i'm using this elsewhere in my code and i may be missing something but i'm pretty sure it looks like my working code.  I just can't get this to work... it always gives me a null reference exception.</p>
  
  <p>hoping someone can lend a hand</p>
  
  <p>~~~~~
  i'm confused even more now....this is from Microsoft site
  <a href="http://msdn.microsoft.com/en-us/library/ff626521%28v=VS.92%29.aspx" rel="nofollow">this is from Microsoft site</a></p>
  
  <p>~~~~~~
  when i set a breakpoint on the   </p>
  
  <pre><code>NavigationService.Navigate(New Uri(x.itsURI, UriKind.Relative)), x.itsURI = "/Pages/WSError/Listing.xaml?SiteID=2&amp;Access=Cossack"
  </code></pre>
  
  <p>if i progress one step past the <code>NavigationService.Navigate</code> and i do a 
   <code>NavigationContext.QueryString.TryGetValue("SiteID", pSiteID)</code>
  the result is False.  Now when i step until i reach the List.xaml page, initializeComponent  is hit and then  <code>NavigationContext.QueryString.TryGetValue("SiteID", pSiteID)</code> comes back as <code>"Unable to evaluate expression."</code> is what shows up when i do the Unable to evaluate expression. in the immediate window.  If i just let the code run, the error is NullReferenceException as unhandled.</p>
  
  <p>hopefully that gives you some better information</p>
  
  <p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Here is what got me around the problem.
  <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.page.onnavigatedto%28v=VS.95%29.aspx" rel="nofollow">Link</a></p>