title: C# - Windows Phone - WebView.Navigate null reference
body: <p>I'm developing UWP app for Windows Phone, but I cannot even start, because I get strange error with <code>WebView</code> element. I also referenced <code>Windows Mobile Extensions for the UWP</code></p>
  
  <p>Here's a code:</p>
  
  <pre><code>XAML
  &lt;Page
      x:Class="App9.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:App9"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"&gt;
  
      &lt;Grid&gt;
          &lt;WebView x:Name="MyWebView" /&gt;
      &lt;/Grid&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>C#
  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Runtime.InteropServices.WindowsRuntime;
  using Windows.Foundation;
  using Windows.Foundation.Collections;
  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Controls;
  using Windows.UI.Xaml.Controls.Primitives;
  using Windows.UI.Xaml.Data;
  using Windows.UI.Xaml.Input;
  using Windows.UI.Xaml.Media;
  using Windows.UI.Xaml.Navigation;
  using Windows.Web.Http;
  
  namespace App9
  {
      public sealed partial class MainPage : Page
      {
          public MainPage()
          {
          }
  
          protected override void OnNavigatedTo(NavigationEventArgs e)
          {
              base.OnNavigatedTo(e);
  
              Uri authorize = new Uri("http://sub.mydomain.com", UriKind.Absolute);
  
              try
              {
                  MyWebView.Navigate(authorize);
              }
              catch(Exception ex)
              {
                  System.Diagnostics.Debug.Write(ex.ToString());
              }
          }
      }
  }
  </code></pre>
  
  <p>and here's an Exception I get:</p>
  
  <pre><code>Exception thrown: 'System.NullReferenceException' in App9.exe
  System.NullReferenceException: Object reference not set to an instance of an object.
     at App9.MainPage.&lt;OnNavigatedTo&gt;d__1.MoveNext()The program '[2912] BandTest.exe' has exited with code 0 (0x0).
  </code></pre>